WordPress.org

Forums

How to use WP_Query() to view just certain posts (2 posts)

  1. damirmerdan
    Member
    Posted 5 years ago #

    Hi, I have following code:

    <?php
    $my_query = new WP_Query('showposts=5&category=featured');
    while ($my_query->have_posts()) : $my_query->the_post();
    echo '<li class="s3sliderImage"><img src='; echo catch_that_image(); echo ' /><span>' . the_title('','',FALSE) . '</span>';
    endwhile;

    ?>

    I am trying to create featured posts slider, which will view only posts from category "featured". When I use the code above, it show me some posts from other category's, even if the category "featured" is empty. So, I'am trying to view only last 5 posts from category "featured". How can I do this.

    Thanks

  2. damirmerdan
    Member
    Posted 5 years ago #

    Solved :) :), I need to use category_name=featured insted of categoty=fatured !

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags