Include PHP file in Content using [shortcode]

Question

Here is what I have

I am not having any lucking finding how to simply include a file in the content editor using a shortcode.

For Example if I wanted to include form.php inside my Contact Page how would I make this happen using a shortcode?

Below is was attempting to work with to no avail.

Any help would be appreciated!

// Shortcode implementation
function magic_stuff($atts) {

// turn on output buffering to capture script output

ob_start();

// include file (contents will get saved in output buffer)

include(TEMPLATEPATH.'/wp-content/themes/grainandmortar/inc_static/test.php');

// save and return the content that has been output

$content = ob_get_clean();
return $content;
}
//register the Shortcode handler
add_shortcode('magic', 'magic_stuff');
0
Eric Downs 4 months 0 Answers 19 views 0

Leave an answer