Support » Networking WordPress » List latest post from all my subscriber-level blogs

  • Hi!

    I am trying to create a page where I can see all the latest posts from the blogs where I have a subscriber-level.

    I’ve been fiddeling with get_blogs_of_user and it leaves me a neat list of all my blogs. However I would prefer if I could just see the ones where I am only a Subscriber.

    So I can find the blogs. Now I want to build a list where all the latest posts appear from those blogs.

    Any ideas?

    Here is some of my code.

    <?php global $current_user;
    	  $blogs = get_blogs_of_user( $current_user->ID );
    	     if($blogs) {
    	     	 foreach ( $blogs as $blog ) {
    	         echo '<li><a href="http://' . $blog->domain . $blog->path .'">' .  $blog->userblog_id . '</a></li>';
    	         global $switched;
    	             echo 'You switched from blog ' . $switched . ' to ' . $blog->userblog_id;
    	             echo 'You switched back.';
    	<?php query_posts( 'blogid=4' );
    		while ( have_posts() ) : the_post(); ?>
    	<?php the_title(); ?>
    	<?php endwhile; ?>
Viewing 1 replies (of 1 total)
  • Here’s an idea, but it generates a pile of queries on the db with more subscriber blogs:

    		$user = get_current_user_id();
    		$blogs = get_blogs_of_user( $user );
    	     if( $blogs ) {
    	     foreach( $blogs as $blog ) {
    		switch_to_blog( $blog->userblog_id );
     			$query = new WP_Query( 'posts_per_page=1' );
     			 	if ($query->have_posts()) :
      					while ($query->have_posts()) : $query->the_post();
    					<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>

    to see more than one post per blog, change posts_per_page=1

Viewing 1 replies (of 1 total)
  • The topic ‘List latest post from all my subscriber-level blogs’ is closed to new replies.