WordPress.org

Ready to get started?Download WordPress

Forums

Replacing switch_to_blog (7 posts)

  1. sunburntkamel
    Member
    Posted 2 years 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. Do they need to be inline or on a sidebar?

    There are plugins that can do this, you see.

  3. sunburntkamel
    Member
    Posted 2 years 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. 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 2 years 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 2 years ago #

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

  7. Caching is magic.

Topic Closed

This topic has been closed to new replies.

About this Topic