1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
// read file function include_template_file ($template_path=null) { if($template_path == null) return ''; ob_start(); load_template( get_template_directory() .'/'. $template_path ); $content = ob_get_contents(); ob_end_clean(); return $content; } // shortcode code function include_template_shortcode($atts, $content=''){ extract( shortcode_atts( array( 'path' => null ), $atts ) ); return include_template_file($path); } add_shortcode( 'include_template', 'include_template_shortcode' ); // Example: // [include_template path='assets/my-file.php'] |