The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Loop to display from certain categories (1 post)

  1. ThorHammer
    Posted 3 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic