• On my main page: https://azfans.com/recent-posts/

    I display the first story at the top “Top Story” followed by the other most recent posts. I would like to also display the 10 latest posts from specific categories, just like my “Recent Blog Posts.” below.

    How would I grab the latest 10 posts from a category to put on this page?

    Currently, to have the most recent 6 posts from ALL categories, I have:

    <?php $my_query = new WP_Query('showposts=6');
    
    if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); 
    
      if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    
                        <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a><span class="smdate"><?php the_time('j M') ?></span></li>
    
     <?php endwhile; endif; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • $my_query = new WP_Query('cat=X&showposts=10');

    Where ‘X’ is the cat ID

    Thread Starter dbunit16

    (@dbunit16)

    Just found this. It’s working!

    <ul>
    <?php
     global $post;
     $myposts = get_posts('numberposts=5&offset=1&category=3');
     foreach($myposts as $post) :
     setup_postdata($post);
     ?>
    
    <li><?php the_title(); ?> </li>
    <?php endforeach; ?>
    </ul>

    Hi,
    Can anyone help me with the following please?

    I want to hide couple of articles from the Recent Posts section. Not from unregistered users, from everyone. I’ve a separate section for those so don’t want to duplicate. And I’ve a separate category for those articles too, say “Special Category” and the ID of that Category is 2. Now how can I do the following? I have:

    1. post 1
    2. post 2
    3. post 3
    4. and so on

    Now I want to hide say post 1 & post 2 (which are under “Special Category”) from the Recent Post list. How can I achieve that? I do host my own site and like million others I use WordPress.

    Please help.

    Regards.

    is it possible to make the sidebar display something like this:

    RECENT POSTS
    ————
    ART (CATEGORY):
    NEW POST 1
    NEW POST 2

    MUSIC (CATEGORY):
    NEW POST 1
    NEW POST 2

    So basically instead of display all new posts from all categories under recent posts it shows them under their categories?

    I have 6 or 7 seperate categories on my blog that I want to treat almost like seperate blogs, hence this question..

    any help much appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Recent Posts from Category’ is closed to new replies.