• jumust

    (@jumust)


    Hi,
    I use the code below to display in my blog page only the last post from each category and IT WORKS PERFECTLY

    <?php // cycle through categories, print 1 post for each category
    $categories=get_categories('orderby=&order=ASC&');
      foreach($categories as $category) {
          $posts=get_posts('showposts=1&cat='. $category->term_id);
    
            foreach($posts as $post) {
              setup_postdata($post); ?>

    So I have i.e :
    Category A –> Last post (a)
    Category B –> Last post (b)
    Category C –> Last post (c)
    …..

    If I publish a post that belongs to Category A and B, in the home page I’ll get
    Category A –> Last post (a)
    Category A –> Last post (a) – same post above
    Category C –> Last post (c)

    Is there a way to keep the category B to show up with the last post as before, and only the Category A to show up with the post just published?

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Last post from each category works – but if a post belons to 2 cat?’ is closed to new replies.