Wordpress Question - Grab Posts from a Category

Discussion in 'WordPress' started by Sam Designs, Jan 27, 2008.

  1. #1
    <?php
    $my_query = new WP_Query('category_name=featured&showposts=1');
    if (have_posts()) : while (have_posts()) : the_post();
    update_post_caches($posts);
    $name = the_title('','',false);
    $name = ShortenText($name);
    ?>

    <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php echo $name; ?></a></li>

    <?php endwhile; endif; ?>

    I use that script to grab all the post titles and links in the featured category, then put them in a list. It works fine on index.php - but when it's on any other page - it just grabs all the pages from the current category, or the current page etc.

    Anyway to make it so it works on every page?

    Thank you,
    Sam.
     
    Sam Designs, Jan 27, 2008 IP
  2. Sam Designs

    Sam Designs Active Member

    Messages:
    474
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Any ideas?
     
    Sam Designs, Jan 28, 2008 IP