I'm a noob at this so please bear with me.

I have the following code to return post title as links within categoryID 6, which is working fine:

<?php global $post; $cat_posts = get_posts('numberposts=10&category=6');
  foreach($cat_posts as $post) : ?>
    <?php $postTitle = get_the_title(); if($title != $postTitle) :?>
    <li><a href="<?php the_permalink(); ?>">&rsaquo;&rsaquo; <?php the_title(); ?></a></li>
    <?php endif ;?>
<?php endforeach; ?>

However, the category ID is a variable, e.g. $catID, can I use this in the above code?

Thanks in advance!

link|improve this question
feedback

1 Answer

up vote 3 down vote accepted

Have you tried the following code?

$cat_posts = get_posts('numberposts=10&category='.$catID);
link|improve this answer
That worked a treat - thanks Lea! – user3907 Mar 13 '11 at 9:44
feedback

Your Answer

 
or
required, but never shown