The MU forums have moved to WordPress.org

Pulling Sitewide Blog Posts to the Main Page (11 posts)

  1. ciaravino
    Member
    Posted 14 years ago #

    I know this has been asked a lot, and I've looked at most of the posts about it. I tried using the Sitewide Tags plugin, but I couldn't really get it to work and I looked at the php file and it had way more than I need anyway. It sounds simple, but I guess it's not.

    I'm trying to get http://gamingapple.com/ to display 5-10 of the most recent posts from each of the 3 other blogs I have on the MU installation. I don't need that much information, just like the title of the post, what blog it comes from, the date and maybe the author of it. I have a blog specifically for Mac, one for iPad, and the other is for iPhone. I think have the root blog as a portal to the other blogs. You should be able to see what I'm trying to accomplish by the information displayed on the http://gamingapple.com.

    In addition to the most recent posts being displayed on the root page, I would like to have 4 different RSS feeds. I would like people to be able to subscribe to the root RSS feed if they want news about all (mac, ipad, iphone) without having to subscribe to 3 individual ones. Then, each blog would have it's own RSS feed. I don't know why the RSS feeds are coming up all broken at the moment, I'll have to see what I messed up.

    Thanks!

  2. dsader
    Member
    Posted 14 years ago #

    You could embed each of 3 RSS feeds from 3 blogs on the main page: <a href="http://codex.wordpress.org/Function_Reference/fetch_rss#Example
    ">fetch_rss example.

    Or create sidebar widget areas in your main blog theme and drop in multiple instances of the default RSS widget.

    IMHO, the sitewide aggregate RSS feed of all blogs in one feed you'll only get as a result of installing Sitewide Tags.

    The short term fix for what you already have could be to wrap each of your 3 loops/searchforms with the switch_to_blog and restore_current_blog functions:

    <div class="left">
    <?php switch_to_blog(2); //mac blog id
    			get_template_part( 'loop', 'index' );
    			include (TEMPLATEPATH . '/searchform.php');
    restore_current_blog(); ?>
    </div>
    
    <div class="right">
    <?php switch_to_blog(3); //iphone blog id
    			get_template_part( 'loop', 'index' );
    			include (TEMPLATEPATH . '/searchform.php');
    restore_current_blog(); ?>
    </div>
    
    <div class="middle">
    <?php switch_to_blog(4); //ipad blog id
    			get_template_part( 'loop', 'index' );
    			include (TEMPLATEPATH . '/searchform.php');
    restore_current_blog(); ?>
    </div>

    I say "short term" as I can't predict what memory/cpu you'll need using switch_to_blog in this way, though, ie. if your site is huge and popular.

  3. ciaravino
    Member
    Posted 14 years ago #

    I tried your code for the switch and restore functions but I get "Call to undefined function get_template_part()".

    When I tried Sitewide Tags it was like changing where posts were. Like, I would make a post in mac.gamingapple.com/sample-post and it would show up on the list but it was under just gamingapple.com/sample-post. I don't know, I didn't really find any documentation for it. I wouldn't mind using Sitewide Tags if it was the easiest.

    Also, do you have any idea as to why my RSS feeds just come out on the page when you click RSS at the bottom?

    I looked at fetch_feed and it looks like it would be good enough if I could get my RSS working correctly. I just don't think I'd be able to have an RSS that would combine all the sub blogs.

  4. dsader
    Member
    Posted 14 years ago #

    Sorry, get_template_part is for WP3. Use the loop you have instead.

    Sitewide Tags will duplicate the posts in the main blog, but the url will/should still send you back to the originating blog.

    Your RSS link in your footer works correctly as far as I can tell, RSS is a valid feed link.

  5. ciaravino
    Member
    Posted 14 years ago #

    Okay, I'll try what I was previously using instead of get_template_part. But, this brings me to another question. I heard that WP3 will replace WPMU. Would it be better if I just started off with that using the nightly builds or whatever instead of building for WPMU then having to switch? Does WP3 offer an easier solution for what I'm trying to do?

    Do you know of any good documentation for Sitewide Tags? The main author's site doesn't have anything. I read the readme but that didn't help me enough, I guess.

    Ah, you're right about the RSS. I guess I'm just used to it popping up and asking you to save it in your default reader when you click it.

    Thanks for helping me out!

  6. ciaravino
    Member
    Posted 14 years ago #

    I used the other information and it works PERFECTLY! It's exactly how I wanted the recent posts to work and it seems like a very simple fix. There's still the RSS problem, but it's not THAT big of a deal. Is there any way to make a RSS feed that combines all of the RSS feeds from all your blogs?

    You did have doubts though, about this strategy - about it maybe being to dependent on resources? I have a business hosting plan over at Host Gator. It's unlimited everything, but of course, I don't know how much it can handle at the same time. I doubt my site will ever be that popular, and certainly not any time soon. But, it is an important issue. I have it set to pull the 10 most recent posts from each blog. Would it help a lot if I took it down to 5 posts, or is that not really the problem?

    Thanks again!

  7. dsader
    Member
    Posted 14 years ago #

    If it were me, I'd start over with a fresh install of WP3 right off the hop (let it build new DB and everything, keep your wp-content/themes/ obviously). There is a bit of finagling to upgrade to 3.0 from WPMU you may prefer to avoid. I haven't upgraded a live site to 3.0 yet, but will do several in the next weeks/months.

    WP3 does not have site-wide aggregation built in. You'd be in the same place you are now. Any method I suggest above would/should still work.

    Sitewide Tags works with 3.0 as far as I know. Donncha's plugin doesn't have much documentation because it doesn't need much, IMHO. Drop it in mu-plugins, check SiteAdmin(aka SuperAdmin)->Options page. Fiddle away with your template using the same codex as for single WP.

  8. dsader
    Member
    Posted 14 years ago #

    Almost forgot about pipes. Could work for your install to aggregate a handful of feeds into one.

    http://pipes.yahoo.com/pipes/

  9. ciaravino
    Member
    Posted 14 years ago #

    I made a pipe and it works. What's the best way to offer your custom feed? I just made the RSS link in the footer go to http://pipes.yahoo.com/gamingapple/allblogs. Would there be any way to make that feed somehow be part of gamingapple.com? So, like, in Google Reader if you want to "Add a subscription", you just type the name of the website, like gamingapple.com and it gets the feed automatically. It works that way on mac.gamingapple.com and the others, and that would be ideal for the combined feed :D

  10. r@keshD
    Member
    Posted 14 years ago #

    you can use this code:

    <?php
    $blog_list = get_blog_list( 0, 'all' );
    foreach ($blog_list AS $blog){
    $domain = $wpdb->get_var( "SELECT domain FROM {$wpdb->blogs} WHERE blog_id=".$blog['blog_id']);
    
    $posts = $wpdb->get_col( "SELECT ID FROM wp_".$blog['blog_id']."_posts WHERE guid like '%".$domain."%'");
    foreach($posts as $p)
    {
    $postdetail=get_blog_post($blog['blog_id'],$p);
    ?>
    <a href="<?php echo $postdetail->guid;?>"><?php echo $postdetail->post_title;?></a>;
    
    <br />
    <?php
    }
    }
    ?>

    Above code retrieves all posts from all existing blogs,You can limit the number of posts using LIMIT clause in database SELECT query .
    get_blog_post function returns an object containing the informations about post.
    Hope ,it will help you.....

  11. ciaravino
    Member
    Posted 14 years ago #

    Would that method be less stressful on the server?

About this Topic

  • Started 14 years ago by ciaravino
  • Latest reply from ciaravino