Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

On my homepage I have a slider at the top and then three columns below that. I would like to pull the three latest post for a category in each column. So each column will have three post titles and dates for a single category.

Can anyone tell me what the Query would be?

Thanks in advance,

14ner

share|improve this question

1 Answer 1

Try this:

<ul>
<?php
global $post;
$args = array( 'numberposts' => 5, 'category' => 1 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :  setup_postdata($post); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> - <?php the_date(); ?></li>
<?php endforeach; ?>
</ul>

More info: query_posts()

share|improve this answer
    
Thanks for the reply. I was wondering if there is a way to use category "name" not id number because for some reason my events category doesn't work. I was also wonder if there was a way to list these post titles without bullets. Thanks, 14ner –  user3992 Mar 16 '11 at 18:24
    
@14ner category name can be easily converted to IF with get_cat_ID() function. –  Rarst Mar 16 '11 at 20:46
    
To remove bullets, see the "Applying the CSS" section of this page of the WordPress documentation: codex.wordpress.org/Creating_Horizontal_Menus –  GavinR Mar 25 '11 at 13:17

Your Answer

 
discard

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