Can someone please help me figure out if the "List category posts" plugin is the easiest solution to my problem:

My goal is to be able to choose which posts are displayed on our homepage under "Latest News". Right now, all new blog posts published are featured in "Latest News." I'd like to be able to create new blog posts and based on the category selected, they will either show up on the homepage, or just be added to our blog.

This is the current code I have in the home.php file for the "Latest News" box on my homepage:

$args = array( 'numberposts' => '5' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
    echo '<a style="font-size: 18px;font-weight: bold" href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >'.$recent["post_title"].'</a><p>'.$recent["post_excerpt"].'</p><hr> ';

We also have a Custom Field set up for "Content under Latest News." I'm not sure if my solution has anything to do with this. I'm familiar with HTML and CSS, and am in the process of learning more about PHP, so any suggestions on this question would be super appreciated!

1 Answer 1


You have to know the ID/s of the category/categories you wish to show. Then add 'category' => 'X' in the array. X is the ID of your category. Example: $args = array( 'numberposts' => '5', 'category' => '3' ); or if you wish more then one category: $args = array( 'numberposts' => '5', 'category' => '3,6,7' );

  • Perfect! That solved my problem perfectly. Cannot thank you enough for your help!!
    – Kristin
    Commented Apr 15, 2014 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.