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. Can I then get the functions.php to check what the variable has been set to and then register post types depending of this variable?

eg. If the brandX then register post types A & C, if brandY then register post type B, if BrandC then register none.

2 Answers 2


If you can get a dynamic variable value of the brand, then you can load wanted CPT.

Inside function.php Create a link to your new function "remove_cpt_multisite". Ex:

// Remove menu items for users 
include (TEMPLATEPATH . '/assets/functions/remove_cpt_multisite.php');

The template itself (remove_cpt_multisite.php) :

       add_action( 'admin_init', 'my_remove_menu_pages' );
       function my_remove_menu_pages() {
          $my_brand_variable = "get your variable";
          // According to the value add wanted CPT with a switch
          switch ($my_brand_variable) {
             case "brand1":
                include (TEMPLATEPATH . '/assets/functions/register_cpt_1.php');
                include (TEMPLATEPATH . '/assets/functions/register_cpt_5.php');
             case "brand2":
                include (TEMPLATEPATH . '/assets/functions/register_cpt_1.php');
                include (TEMPLATEPATH . '/assets/functions/register_cpt_2.php');
  • Hi, thanks for that. I can't see to get the function.php to see the variable thou. I'm having to use a bought theme, so I'm having to hack around what's already there. When I set the variable in the themes options I can see it frontend: echo $_mc_option['brand_choice'];. The dev seems to call his theme option variables by the following method, which I can't duplicate: global $_mc_option; if ($_mc_option['brand_choice']) { $my_brand_variable = $_mc_option['brand_choice']; }
    – CuCo
    Jul 21, 2014 at 16:49
  • Have you tried to add my function at the end off the function.php template? Otherwise, if you have the information saved inside your theme option, simply get this information directly from the database.
    – Romain
    Jul 21, 2014 at 17:29
  • Note: global $_mc_option; will difine globally the variable within the scop
    – Romain
    Jul 21, 2014 at 17:30
  • I've got the function as the last thing in the function.php, but it still doesn't pull in the "brand_choice" variable or if it does it's not passing it on tp $my_brand_variable. I have it set up as follows: add_action( 'admin_init', 'my_remove_menu_pages' ); function my_remove_menu_pages() { global $_mc_option; if ($_mc_option['brand_choice']) { $my_brand_variable = $_mc_option['brand_choice']; } switch ($my_brand_variable) { case "brand1":
    – CuCo
    Jul 21, 2014 at 18:48
  • Alternatively how would I get the info directly from the DB, as it's a multisite there are 6 sets of tables?
    – CuCo
    Jul 21, 2014 at 18:52

Right I have come at this from a different angle. I registered all the posts as normal. And then depending of the variable set it will remove the menu from the backend.

function remove_menu_items() {
    global $brandChoice; 
    if ( $brandChoice == 'brand1' ) {
        remove_menu_page( 'edit.php?post_type=cpt1' );
    } else if ( $brandChoice == 'brand2' ) {
        remove_menu_page( 'edit.php?post_type=cpt2' );
    } else {
        // something else
add_action( 'admin_menu', 'remove_menu_items' );

This is now working as I hoped, As I change the brand in the brand variable in the themes options and then load any other backend page the menu structure changes to only show the CPT I want to see.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.