WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
up vote 0 down vote accepted

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' );

share|improve this answer
Perfect! That solved my problem perfectly. Cannot thank you enough for your help!! – Kristin Apr 15 '14 at 17:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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