Switch Site Rewrite
[resolved] custom post types and switch_to_blog (4 posts)

  1. Bill Dennen
    Posted 4 years ago #


    I have a multisite network set up. For simplicity, let's assume there are only two sites (in reality, we have many more).

    Site A == defines a custom post type (faculty_profile)
    Site B == we'd like to pull in a list of faculty_profiles from Site A

    I have it working, using code like this:


    This seems to work ok. The list of posts is pulled fine. But, the permalinks are not correct.

    Instead of the pretty CPT permalinks, I get


    While the link isn't correct, it does redirect to the proper link.

    ie; http://somesite.com/sitea/faculty/some-slug/

    Even with switch-site-rewrite, I get the same results.

    Could someone point out what I am doing wrong here? Thanks.


  2. Ron Rennick
    MultiSite Guru
    Plugin Contributor

    Posted 4 years ago #

    Is the custom post type registered in the second site?

  3. Bill Dennen
    Posted 4 years ago #

    Thanks Ron. It's not registered. But, I will try that and see what happens. I wanted to avoid it...

  4. Bill Dennen
    Posted 4 years ago #

    Thanks Things seem better when the post type is registered. No more permalink issues.

    Is it proper to "temporarily" register the post type when the shortcode is called? I'm first checking to see if the post type is registered, with:

    if ( !post_type_exists( 'faculty_profile' ) )

    If it's not registered, I register it. If it is registered, I assume things will work.

    Is there a better way to do that?

    edit: saw your tweet about looking at how sitewide tags does it. I'll take a look. thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Switch Site Rewrite
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic