wjdennen
Member
Posted 1 year ago #
Hi,
I am putting together a shortcode that will display a list of posts which are of a custom post type. This is straightforward to do within the blog that defines the custom post type.
But, if the custom post type is defined in Blog A and I want to display the list (via shortcode) in Blog B, what is the best method?
Using switch_to_blog? using a custom query?
One problem is that the custom post type is currently only defined (registered) in Blog A. Would it also need to be defined in Blog B?
Thanks
You should be able to use switch_to_blog, which will then use whatever is registered in Blog A, without needing to worry about what is registered in Site B. People have been having issues with switch_to_blog, from what I've seen, so test it and see what happens.
Switch_to_blog has issues with both scalability and permalinks, but it should be able to do that, without registration.
wjdennen
Member
Posted 1 year ago #
Thank you. I can verify that switch_to_blog works fine.
I am running into a problem with permalinks, as you mentioned. Even with Switch Site Rewrite enabled, I am seeing a problem. Basically, permalink structure is not correct, but the links do seem to work.
http://wordpress.org/extend/plugins/switch-site-rewrite/
Yeah, I did some massive handcrafting for a while to make it work, but basically I ended up calling in JUST the post number and then calling subsite.domain.com/?p=<postnumber> to force it.