WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Types not on Subsite (8 posts)

  1. rrasco
    Member
    Posted 11 months ago #

    I have scoured to the ends of the Internet without an answer, so I come to the masses...

    I just developed a new theme for a site I inherited. This install has 6-7 subsites. I installed the theme on the network and activated it on the main site and one of the subsites (dev site). There are two custom post types I defined in the functions.php but they are only registering on the main site and not on the subsite.

    I tried the Custom Post Type UI plugin to see if they were even registering but they only appear on the main site. No menu items and as far as I can tell the subsite doesn't see them at all.

    I setup a multisite environment on a separate server and the CPT are available on all subsites with the theme activated so I'm assuming something is goofed up with the other install I inherited, but I'm not sure where to start looking.

    register_post_type( 'slides',
            array(
                'labels' => array(
                    'name' => __( 'Slides' ),
                    'singular_name' => __( 'Slide' )
                ),
            'public' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'has_archive' => false,
            'exclude_from_search' => true,
                'supports' => array(
                    'title',
                    'editor',
                    'thumbnail',
                    'revisions'
                )
            )
        );
  2. There are two custom post types I defined in the functions.php but they are only registering on the main site and not on the subsite.

    The functions.php file is for the specific theme, NOT the network. Are you sure that theme is in use on all sites on the network?

  3. rrasco
    Member
    Posted 11 months ago #

    I realize the functions.php file is for the specific theme.

    The client wanted the site on their server before going live, so what I did was create subsite new.domain.com, it's a dev site. This is the subsite the CPT are not working on. I also tested this theme on the main site (domain.com) in which the CPT work. So, the theme is not in use on ALL sites, but it is in use on the two sites I am trying to work on. One dev, one production. It is currently the active theme on the dev site, in which I would expect the functions.php file to load and register the CPT. This is not the case.

  4. I can't know what you know if you don't tell me :) I try not to make assumptions since you're asking for assistance, after all.

    Double check the theme is active on the sub-site, and it's not a child theme or such. Also remember to make sure you flush any caches.

    Still not working? Put the theme on a totally separate dev site (like a localhost site) and see if it works there. It may be tied in to other features on the main site that you've not fully replicated.

  5. rrasco
    Member
    Posted 11 months ago #

    I understand, but I believe I explained that all in my first post.

    The theme is active on the subsite. It is not a child theme.

    My first post also states this works on a separate server I originally developed this theme on. I added a subsite to that MP environment after I encountered this issue to test and it does work on both the main and subsite there.

    Is there a native WP cache I am overlooking? I do not believe there is any other cache system installed. I will double check though.

  6. You would be surprised how many time I have to ask and re-ask for clarification on what someone means when they say things :/ Language is tricky and sometimes people use non-standard terms.

    There's no native WP cache at all.

    You didn't (or rather your predecessor didn't) put any checks around the functions to make them only run on ONE site? I do that fairly often so not everyone has the CPTs.

    Finally ... Test on a NON Multisite, totally separate, localhost instance. There's a reason for that :) You want to pull out variables, and the first place you check "Is it me or is it Multisite?" is by throwing up a clean install of nothing but plain WP, tossing the theme on (no plugins, nothing) and see what happens.

  7. rrasco
    Member
    Posted 11 months ago #

    Actually I wouldn't be, I work in IT as a network admin so I am used to vague or incorrect jargon, excuses, etc. I try to put as much info in my posts without deferring from the important stuff. At any rate...

    I have no idea what the previous devs did. This is my first multisite environment. I did however build this theme on a non-MS site so I am fairly certain it works as a standalone feature. I'm rather confused because registering a custom post type is fairly simple in and of itself.

    When you say 'checks', do you mean conditional statements to check which subsite is running? Say, something similar to:

    if(this-site) { register_post_type() }

    I'm almost positive it's something to do with the MS env I inherited, I was just looking for leads on what next to check because I've run out of ideas. I've gone through all the standard stuff. I was thinking it might have something do to with the other themes on the network, there are about 8-9; one for each subsite. I'm tempted to delete them, but that would break the rest of the network. I know I've worked on some sites where the prev dev hacked together themes and broke stuff like page templates, etc.

  8. I did however build this theme on a non-MS site so I am fairly certain it works as a standalone feature.

    So on a clean single site, it's good.

    When you say 'checks', do you mean conditional statements to check which subsite is running? Say, something similar to:

    if(this-site) { register_post_type() }

    Yes, like that.

    It won't have anything to do with the non-active themes, since they're ... not active.

Reply

You must log in to post.

About this Topic