Can you get the themes options page to turn on/off which custom post types are r
-
I have a theme that is being used for a multisite installation that will be used by 6 sub-brands of an organization. Each sub-brand will only require some of the custom post types set up by the theme – thus I would like to hide the ones not needed.
The theme has an options page where I can set a variable to state which brand is using the theme. I then want the functions.php to check what the variable has been set and then register the relevant post types.
eg. If the brandX then register post types A & C, if brandY then register post type B, if BrandC then register none.
Here is what I have done so far, the theme is a purchased theme so I’m having to hack around with what has already be written. Within the theme-options.php after I set up the “brand” option I have added:
global $brandChoice; if(isset($data['brand_choice'])){ $brandChoice = $data['brand_choice']; }
I have echoed $brandChoice into the header.php and the function.php and it will display that variable front & back end plus it will change as I change the brand to another brand.
The next bit of code doesn’t seem to work:
add_action( 'admin_init', 'my_remove_menu_pages' ); function my_remove_menu_pages() { global $brandChoice; echo 'Variable: '.$brandChoice; //This displays correct brand name at the top of the page if ( $brandChoice == 'option1' ) { register_post_type( 'nameHere', array( //etc
- The topic ‘Can you get the themes options page to turn on/off which custom post types are r’ is closed to new replies.