Forums

Replacing switch_to_blog (7 posts)

  1. sunburntkamel
    Member
    Posted 8 months ago #

    I'm working on a multisite instance where I need to pull in posts from a subsite, into the main site. It looks like switch_to_blog used to do this, in WPMU, but it no longer works.

    http://pastebin.com/EL0Ag4jH

    So I created a function to grab the latest X posts from a given blog's table directly (via wpdb), and then a second function to grab some additional post meta information. I built a loop to display the posts. It's mostly working, but now I've increased my mysql queries by 50, and my page rendering time has gone up from .415 seconds to 1.6 seconds.

    anything I can do to cut this down?

  2. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 8 months ago #

    Do they need to be inline or on a sidebar?

    There are plugins that can do this, you see.

  3. sunburntkamel
    Member
    Posted 8 months ago #

    inline. what plugins should I be looking at? if they do it in the sidebar, I can just look at how they do it.

  4. Andrea_r
    team pirate
    Posted 8 months ago #

    http://wordpress.org/extend/plugins/diamond-multisite-widgets/ is for sidebar.

    http://wordpress.org/extend/plugins/wordpress-mu-sitewide-tags/ this is what I use on homeschooljournal.net. it copies a post to the main site with the original permalink so no duplicate content on the front end.

    It;s what we always recommend if you;re looking for full posts on the main sit,e as there is no efficient query for this.

  5. sunburntkamel
    Member
    Posted 8 months ago #

    yeah, I'm using sitewide tags elsewhere - basically I need the sitewide tag pages to not be domain.com/blog/categoryname. I'm actually using this code to pull in posts from the sitewide tags blog.

    I'll check out the diamond ms widget

  6. sunburntkamel
    Member
    Posted 8 months ago #

    diamond actually makes 250+ queries on its own, but caches them. I guess caching is my answer ;)

  7. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 8 months ago #

    Caching is magic.

Reply

You must log in to post.

About this Topic