Support » Fixing WordPress » Last post from each category in home page

  • Hello, i would like to show at my home page one article from every category and also the title of the second article of every category. I Hope you understand what i mean. You can also see a theme that uses exatcly what i need.

    Here is the demo of Portal theme:

    i’m creating a new portal so i would like the news to be shown that way.

    Thank you very much and congrats about wordpress, the best blog(+more) script ever made!!

    Ps. Found several post at the forum but non was a full respond..

Viewing 3 replies - 1 through 3 (of 3 total)
  • <?php
    //get all terms (e.g. categories or post tags), then display 2 posts (1st post displays the_content) in each term
    $taxonomy = 'category';//  e.g. post_tag, category
    $param_type = 'category__in'; //  e.g. tag__in, category__in
      'orderby' => 'name',
      'order' => 'ASC'
    $terms = get_terms($taxonomy,$term_args);
    if ($terms) {
      foreach( $terms as $term ) {
          "$param_type" => array($term->term_id),
          'order' => 'ASC',
          'orderby' => 'title',
          'post_type' => 'post',
          'post_status' => 'publish',
          'posts_per_page' => 2,
          'caller_get_posts'=> 1
        $my_query = null;
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          $count = 0;
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           $count ++;
           if ($count == 1) {
    wp_reset_query();  // Restore global post data stomped by the_post().

    thank you very much. as i can see that’s exactly what i was looking for.

    the problem now is how i’m gonna make it look like my theme..

    could you make this work to only display children of the current category – or a specific category?


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Last post from each category in home page’ is closed to new replies.