[wp-hackers] switch_to_blog in WP3
Bill Dennen
dennen at gmail.com
Fri Jul 30 15:29:11 UTC 2010
Hi,
I wrote a plugin that allows one blog to pull posts in from another
blog via shortcode. I call it get-news. The syntax of the shortcode is
something like this:
[get-news site_name="news" numberposts="10" show_dates="0"]
In short, what this code does is switch to the blog located at /news/
and grab the 10 most recent posts and display them on the current
blog. There are other options, as well - like pulling posts by
category or tags, showing thumbnails, etc.
My code uses switch_to_blog to do this. I've read that this function
has a heavy performance hit. But, we've been using it with WP Super
Cache and it has worked well for us in WPMU 2.9.2. Plus, at this
point, my plugin is not meant for distribution -- it's used only on
the site I manage. (That could change...)
Now, my code is broken in WP3.x. Permalinks are incorrect and
thumbnails do not work properly.
I believe it's this bug, which is now listed as a "wontfix":
http://core.trac.wordpress.org/ticket/12040
In the bug report, there is mention that this bug could be 'fixed' via
a plugin via the switch_blog hook.
I'm looking for alternate suggestions for ways to do this. At this
point, this bug is holding us back from going with WP3, which we'd
like to do for many reasons!
One option I toyed with initially was using RSS feeds, but I could not
get the thumbnails over that way.
Looking forward to any suggestions.
Thanks-
Bill
More information about the wp-hackers
mailing list