New answers tagged


As @toscho mentioned in his comment, your best bet is probably an autoloader of some sort... foreach ( glob( plugin_dir_path( __FILE__ ) . "subfolder/*.php" ) as $file ) { include_once $file; } There are plugins that do this kind of thing or possilby something like code snippets, but I'll add some examples below... Example for basic ...


I store core functions in a parent theme, then load site-specific functions to a child theme. Benefits: Decluttering the (child) theme with code that hardly ever changes per in-house preferences. Ability to push new core functionality to many installations by simply updating the parent theme.


Ok, first I'd ditch the output buffering. Second change: include(TEMPLATEPATH.'/wp-content/themes/grainandmortar/inc_static/test.php'); To include( get_stylesheet_directory() . '/inc_static/test.php'); Finally, Reading the documentation here: You need to return something, if your test.php doesn't output ...


Here's another way to do it, utilizing get_template_part of wordpress function include_file($atts) { $a = shortcode_atts( array( 'slug' => 'NULL', ), $atts ); if($slug != 'NULL'){ ob_start(); get_template_part($a['slug']); return ob_get_clean(); } } add_shortcode('include', 'include_file'); ...

Top 50 recent answers are included