views:

109

answers:

2

I wanted to show post from just recent post from a specific categories

so far this is what I have but:

<ul>
    <?php
    $number_recents_post = 5;
      $recent_posts = wp_get_recent_posts($number_recents_post);
      foreach($recent_posts as $post){
        echo '<li><a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' .   $post["post_title"].'</a> </li> ';
      } ?>
    </ul>

I tried turning it into this but not working

<ul>
    <?php
    $number_recents_post = 5;
      $recent_posts = wp_get_recent_posts($number_recents_post . 'cat=3,4,5');
      foreach($recent_posts as $post){
        echo '<li><a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' .   $post["post_title"].'</a> </li> ';
      } ?>
    </ul>

Please let me know what am I doing wrong....

A: 

why don't you try this (assuming you are using Wordpress)

<?php query_posts('post_per_page=5&category_name=yourcategoryname'); ?>
<?php if ( have_posts() ) : while (have_posts()) : the_post(); ?>

<?php endwhile; else: ?>

<p>An error Message</p>

<?php endif; ?>
codedude
i did that but now the problem is that all the post links to the recent one...
kwek-kwek
bother....sorry-I'm not sure how to fix that :(
codedude
+1  A: 

According to the Codex, you can't use wp_get_recent_posts() the way you do:

Parameters

$num (integer) (optional) Number of posts to get.

Default: 10

Maybe codedude's example helps.

Pekka