I am including a PHP file on a WordPress page like this: [include filepath='/my_file.php']
The part of the functions.php
that I changed to make it possible looks like this:
function include_file($atts) {
extract(shortcode_atts(array('filepath' => NULL), $atts));
if ($filepath!='NULL' && file_exists( trailingslashit( get_stylesheet_directory() ) . $filepath)){
ob_start();
include(get_stylesheet_directory() . '/' . $filepath);
$content = ob_get_clean();
return $content;
}
}
However, I want to be able to send a variable with the include. It is not possible like this: [include filepath='/my_file.php?var=1']
, but maybe you get the idea.
Right now, I created a lot of different .php files which have the variables in them and included them like this:
[include filepath='/my_file1.php'][include filepath='/my_file2.php']
This is really annoying to deal with and if I change something in the original php, every other one has to be changed. Is there a better way? :)