Support » Themes and Templates » Loop to display from certain categories

  • My front page (mother site) are supposed to be a specific page template showing the last 10 posts from category 3 and 4 (in separate sidebars/columns) from the blogs in my multisite install. (users can post in one of these two categories – only).

    This is the code (almost without styling) I tried:

    <?php get_header(); ?>
    <div class="container">
    //display 10 posts from category id 4
          'cat' => 4,
          'post_type' => 'post',
          'post_status' => 'publish',
          'posts_per_page' => 10,
          'caller_get_posts'=> 1
        $my_query = null;
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo '<li>';
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p>echo get_avatar( get_the_author_email(), '50' );</p>
          <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
          <p><?php the_time('F j, Y') ?></p>
          <p><?php the_excerpt(); ?></p> /*excerpt limited in functions php */
          echo '</li>';
    ... repeat for the ten posts in categori id 3

    But it doesn’t work. My goal was to display the latest posts from all users posting in the specific category, showing each of the latest posts with their gravatar, the title, the date and the (shortened) excerpt. The loop above must miss something, I suspect it doesn’t look into the different blogs, only in the mother blog (which is without posts). Any advice?

  • The topic ‘Loop to display from certain categories’ is closed to new replies.