WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Bill Dennen
    Member
    Posted 3 years ago #

    Hi,

    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:

    http://pastebin.com/APJ3brnf

    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

    http://somesite.com/sitea/2011/03/07/some-slug/

    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.

    http://wordpress.org/extend/plugins/switch-site-rewrite/

  2. Ron Rennick
    MultiSite Guru
    Plugin Contributor

    Posted 3 years ago #

    Is the custom post type registered in the second site?

  3. Bill Dennen
    Member
    Posted 3 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
    Member
    Posted 3 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

About this Topic