• Erik

    (@southernutahautism)


    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?

Viewing 10 replies - 1 through 10 (of 10 total)
  • 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!

    You can do something like:

    https://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 https://www.htmlcenter.com/blog/wordpress-multi-site-get-a-featured-image-from-another-blog/

    Thread Starter Erik

    (@southernutahautism)

    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.

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

    Thread Starter Erik

    (@southernutahautism)

    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.

    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

    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

    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

    Watching this…

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

    Same here…

    Watching this…

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

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Accessing multisite post data from "parent" site’ is closed to new replies.