0

I used Theme Options page from the Tutorial of Ian Stewart in some of my WP site, and it works just fine. What I did externally was this (closest English Tuts). All those sites were single sites. But now I'm dealing with a WordPress Network.

As I'm developing a single theme for all the sub-sites, I'm placing the theme-options.php into my theme as a common file. As per my search, I got a conditional statement:

global $blog_id; if( $blog_id == '1' ) { //do things for first site } 

Do I need to echo the same code of the theme-options.php under two such block to activate different thing in different site?
Or, do I need to made two different theme-options.php and conditionally load them for different site?

 global $blog_id; if( $blog_id == '1' ) { require_once ( get_template_directory() . '/theme-options.php' ); } elseif ( $blog_id == '2' ) { require_once ( get_template_directory() . '/theme-options-bengali.php' ); } else { require_once ( get_template_directory() . '/theme-options.php' ); } 

Please note: Two of my site's settings, in many cases could be different and I'd need to grab them differently for the front-end.

1 Answer 1

1

I could take advantage of get_template_part( $slug, $name ) and use it like:

get_template_part( 'theme-options', get_current_blog_id() ); 

Say we are on blog_id 5, if theme-options-5.php exists it will be loaded. If not theme-options.php will be loaded as a fallback. Please note that get_template_part is using require.

1
  • I got an answer regarding get_template_part() and require_once(): See here^ Commented Apr 16, 2014 at 4:24

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.