The MU forums have moved to WordPress.org

Grabbing most recent posts from all blogs...sort by date? (10 posts)

  1. JsonB123
    Member
    Posted 2 years ago #

    First I was switching to each blog and then using
    $recent = new WP_Query('showposts=1');
    to grab the newest post from each. Then I was just printing it out right there. Then I'd switch to the next blog and so on.

    My issue is that I wish to have these most recent posts sorted chronologically...and since a blog might get queried before another one with a more recent post, this can't happen the way I'm doing it.

    I've changed what I was doing and built a stdObject array up and then sorted it. The only problem with this is now I cannot use "member" functions on it. I get the following error when I try to loop through as I would normally on a post using while($stuff->have_posts()) : $stuff->the_post();

    ERROR:
    Fatal error: Call to a member function have_posts() on a non-object in...

    How can I properly get the most recent entry from each Blog on my site sorted chronologically with newest first and still use the normal loop functions?

  2. tdjcbe
    Member
    Posted 2 years ago #

    Why not just use one of the sitewide tagging solutions that compile the posts and produce a latest post list from that?

  3. JsonB123
    Member
    Posted 2 years ago #

    Well...I've already built this site not using those plugins and I want only the single most recent post from each blog...not the 10 most recent posts regardless of where they come from.

    I could just go through this and try not using the standard functions like the_title(), etc. but I'd like to.

    Basically I have a stdObject array...but I want it to be able to use those above functions. Is there a way to enable it to use the_title(), etc via an include or something of that nature?

  4. andrea_r
    Moderator
    Posted 2 years ago #

    "I want only the single most recent post from each blog."

    The sitewide tags plugin does exactly that.

  5. jsamuel
    Member
    Posted 2 years ago #

    How can i get n number of posts from a particular blog by giving its blog id in the home page?

    something like this?

    <?php query_posts('blog_id=4&posts_per_page=5'); ?>
    <?php while (have_posts()) : the_post(); ?>
    " rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>

    <?php endwhile; ?>

    please help!

    i need multiple blogs of this on my main blog homepage and flexibility to show excerpts, title, or full post. :) asking for too much?

  6. jsamuel
    Member
    Posted 2 years ago #

    i need multiple *blocks* of this on my main blog homepage and flexibility to show excerpts, title, or full post.

  7. andrea_r
    Moderator
    Posted 2 years ago #

    Usually, that excerpts or not is handled via the theme. Look at any magazine theme out there with a bunch of blocks on the main page.

  8. jsamuel
    Member
    Posted 2 years ago #

    thanks andrea,

    but my main problem is to get n number of posts from a particular blog by its blogid (and if possible from a certain category or tag) on the home page of my mainblog

    something like this:
    <?php query_posts('blog_id=4&posts_per_page=5'); ?>

    or

    <?php query_posts('blog_id=4&'category_name=canada&posts_per_page=3'); ?>

    <?php while (have_posts()) : the_post(); ?>
    " rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
    <?php endwhile; ?>

  9. tobbe_l
    Member
    Posted 2 years ago #

    I'm sort of having this issue too. My problem is how to get the original individual blog names show on the new sitewide tags blog. I want to create a mixed RSS feed from that blog and there it's important to show the blog names from each blog.

  10. dsader
    Member
    Posted 2 years ago #

    I use this in the postmeta section of the template on the main(tags) blog to return the original blog name/link:

    <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link(); ?><?php
    	  list($org_blog_id,$post_id) = explode('.', $post->guid);
    	if($org_blog_id) {
    		$blog_details = get_blog_details($org_blog_id);
    		echo '  from <a href="' . $blog_details->siteurl . '">' . $blog_details->blogname . '</a>';
    	} ?> | <a href="<?php comments_link(); ?>">Comments (<?php comments_number('0', '1', '%', 'number'); ?>)</a></small>

    Oh, and I have another function in the template's functions.php to return the comment count, if interested.

About this Topic