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.

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!

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Have you tried the following code?

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

Your Answer

 
discard

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