WordPress.org

Ready to get started?Download WordPress

Forums

Accessing multisite post data from "parent" site (11 posts)

  1. Erik
    Member
    Posted 3 years ago #

    I have a project that consists of one main portal site, and then several sub-sites, which are all run off of WordPress Multisite. There is the main portal page, and then the sub-sites are ran out of directories like "www.domain.com/subsite1" etc etc.

    The portal site is set up like a magazine theme, with a custom layout and loop to pull posts from the main blog. But I'd also like to pull posts from the sub-sites as well, since this is all an interconnected network.

    I tried using RSS feeds from the sub-sites, but it was very slow and not very customizable.

    Ideally, I'd like to be able to set up some sort of query that can be set similar to a loop, and have it pull the post data the same way a magazine theme does on a per-category basis, only this would do it on a per-site basis.

    I have considered making php that will manually query the DB and pull the latest post and it's data, and then format it into the page, but I don't have the mySQL knowledge to do that.

    Right now, I have it set up as an iframe, where each sub-site has a custom page template that shows nothing but one post title and its excerpt. I pull those into iframes on the portal homepage, and it gives the effect I want (dynamically updated from the sub-sites), but the iframe hack isn't SEO friendly, and it's just sloppy overall.

    I know I can't be the first person to want to do this, but I am having a hard time finding any good info. Essentially, I want to make a "magazine" style page, with post from Multisite sub-sites.

    Example layout concept

    Main site Blog post 1 and excerpt
    - Main site blog post 2 title only
    - Main site blog post 3 title only

    Sub site 1 Blog post 1 and excerpt
    - Sub site 1 blog post 2 title only

    Sub Site 2 Blog post 1 and excerpt
    - Sub site 2 post 2 and excerpt

    Sub site 3 post 1 title
    Sub site 4 post 1 title

    Does that make sense? An RSS feed almost pulls this off, but it's not nearly flexible enough, and waiting for the RSS http request really slows things down, even though all the sites are on the same domain and server.

    Has anything like this every been demonstrated to be possible? Or is this something where I'm going to have to have the PHP written to pull the database row for each blog table independently, and output it on the page outside of the WordPress codebase?

  2. springthistle
    Member
    Posted 3 years ago #

    Erik - did you ever get this resolved? I'm trying to figure out similarly questions regarding access sub-blog information on the parent/main site. Let me know if you have anything. Thanks!

  3. Curtiss Grymala
    Member
    Posted 3 years ago #

    You can do something like:

    http://wordpress.pastebin.com/aJnpBLxV

    You can see an example using code similar to this to pull a featured image from a post on a sub-site at http://www.htmlcenter.com/blog/wordpress-multi-site-get-a-featured-image-from-another-blog/

  4. Erik
    Member
    Posted 3 years ago #

    I am actually at the tail end of developing a rather large custom function that will do this.

    Right now it is just designed to pull the latest post data from a specified multisite site, based on the site ID. You just input the site ID # into the page, and then the function handles querying the database for that site ID for the featured thumbnail, the post title, the post name, the permalink, and the excerpt.

    It's been quite an undertaking just to get it this far, we hope to turn it into a plugin, but for right now the function and the snippet on the actual page is working well enough. I will post my finished product here, since through all our research (me and my php guy), no one has done this before.

    Granted, what we are doing is VERY specific, since we just want to be able to show the latest post from multisite blogs, but I am sure it can be easily expanded.

    I also looked into using the Sitewide Tags plugin as part of the solution, but it really didn't help us accomplish what we wanted. It does grab posts from the multisite sites, but the posts are then a part of the sitewide tags blog. What we're making is a method where the "most recent" post appears on the page, and the click-through on the links/images then load that blogs page, not the sitewide tags page.

    It's definitely not something I can release as a plugin or a "one size fits all" solution, but by tomorrow I plan on having it working to our needs, which is
    - Pull the latest post from any specified blog on a multisite install
    - Output that posts featured image thumbnail, permalink, post title, and excerpt
    - Format those elements in any way you we see fit.
    - Handle the query in a function, with only markup and a blog identifier ID on the display page.

    If we get it working well, I hope we can refine it into a widget plugin, because it can easily be extended.

  5. chuckingit
    Member
    Posted 2 years ago #

    Hi Erik - did you ever get this to work and if so can you share ..??.. cheers - chuck scott

  6. Erik
    Member
    Posted 2 years ago #

    I actually did figure something out, it's very kludge and involves querying the wp database and finding a site_ID and stealing rows out of it.... I don't even remember actually.

    BUT, I will post everything I can and see if someone else can make it work on a different site. From what I remember, it involves a new piece of PHP on the page or place you want to retrieve it, and then a bigger block of code in the functions.php file.

    When I get some time to actually sift through it today, I'll reply again. It's really sloppy, but it worked, but it was a very narrow use case that ONLY pulled the top row of the actives posts of a specific site-id in the multisite database...

    yeesh.

  7. chuckingit
    Member
    Posted 2 years ago #

    Hey Erik - thanks for quick response ... yes, would welcome opportunity to look at it as i too have very narrow case ... in that i have a sub blog called photos, and only want to pull the top 3 or 5 thumbs and post titles from that blog id and then show those posts / thumbs as widget in primary site ... can't believe how difficult it has been to try to find a solution thus far but i digress ... cheers - chuck scott

  8. Edd Hurst
    Member
    Posted 2 years ago #

    Ahoy there,

    I'm looking to do something similar to you as well, and it'd be great to check out your code to see if I might adapt it. I'm surprised they took the functionality out of WPMU when they brought it into WP Multisite - it always seemed like such a logical thing to want to do...

    Regardless, any help your code might be able to provide would be awesome.

    Cheers

  9. scottlowe
    Member
    Posted 2 years ago #

    Erik (and anyone else listening)...

    Did you post your code/solution somewhere public? I too have the same need and it appears there is no plugin to speak of.

    Thanks,

    Scott Lowe

  10. thecorkboard
    Member
    Posted 2 years ago #

    Watching this...

    I need to grab sitewide updates to a custom post type based on a custom taxonomy.

  11. Herbert
    Member
    Posted 2 years ago #

    Same here...

    Watching this...

    I need to grab sitewide updates to a custom post type based on a custom taxonomy.

Topic Closed

This topic has been closed to new replies.

About this Topic