How to include a file in shortcode function in wordpress

2022-11-15T17:12:19.000000Z byAdmin inWordPress

hoew to


// 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/prugins/magic-plugin/magic-code.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');