wordpress function files, how to loop require_once? -


i trying loop through require_once statements in wordpress functions.php file this

// initial theme setup require_once locate_template('/inc/init.php');  // register widget areas require_once locate_template('/inc/sidebar.php');  ... 

why following loop not working?

$theme_includes = array(   '/inc/init.php', // initial theme setup   '/inc/sidebar.php', // register widget areas   '/inc/scripts.php', // register scripts , stylesheets   '/inc/nav.php', // main navigation   '/inc/cleanup.php', // cleanup   '/inc/customizer.php',   '/inc/template-tags.php', // custom template tags   '/inc/extras.php', // no theme functions   '/inc/analytics.php' // google analytics  );  foreach ( $theme_includes $include ) {   require_once locate_template( $include ); } 

i no error message files not load

if check the wordpress codex of locate_template() find function takes 3 parameters:

locate_template( $template_names, $load, $require_once ) 
  1. $template_names: should array of files/templates search for
  2. $load: boolean, if set true load file(s) when found
  3. $require_once: boolean, if set true load file(s) using require_once php function

so in case can forget foreach , pass array first parameter , set other 2 params true:

$theme_includes = array(       '/inc/init.php', // initial theme setup       '/inc/sidebar.php', // register widget areas       '/inc/scripts.php', // register scripts , stylesheets       '/inc/nav.php', // main navigation       '/inc/cleanup.php', // cleanup       '/inc/customizer.php',       '/inc/template-tags.php', // custom template tags       '/inc/extras.php', // no theme functions       '/inc/analytics.php' // google analytics );  locate_template( $theme_includes, true, true ); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -