WordPress.org

Ready to get started?Download WordPress

Forums

Any way to retrieve accurate list of post types after switch_to_blog()? (5 posts)

  1. Curtiss Grymala
    Member
    Posted 2 years ago #

    Does anyone know of a way in WordPress Multisite to retrieve an accurate list of the registered post types on a blog other than the one you're currently viewing? When you use the switch_to_blog() function, the list of registered post types isn't reset, so it still returns the registered post types for the blog you were initially working on, rather than returning the list of registered post types for the blog you switched to.

    I'm not sure if this is really even possible, since post types are registered for each individual blog at run time; but I wanted to check to see if anyone had any ideas (outside of initializing the other blog in a new window/frame and trying to return information through JSON(P)). Thank you.

  2. Custom Post Types? How did you add them to the site? If it's in the themes functions.php, I can't see how you'd pull it in...

  3. You can declare custom post types in mu-plugins instead of the theme too.

  4. Yeah, but then they're network wide :/ Unless you do some serious pokery/jiggery with blog switching. Which is the only reason I use a plugin for 'em on one of my sites.

  5. Curtiss Grymala
    Member
    Posted 2 years ago #

    That's kind of what I was afraid of.

    Basically, I'm working on a heavily modified version of the Sitewide Tags plugin, and I wanted to have the code automatically check to see if a post type is supported in the aggregate site before trying to create a copy of it.

    Right now, if I leave the code unchecked, I get an "Unknown Post Type" error when the plugin tries to create a copy on the aggregate site. The only reliable way I've found around it (other than to implement the option of manually indicating which post types should be syndicated) so far is to simply have the plugin ignore all posts that aren't either a "post" or "page".

Topic Closed

This topic has been closed to new replies.

About this Topic