Wordpress Issue

Discussion in 'PHP' started by launchplanet, Oct 2, 2009.

  1. #1
    Hi.

    I'm looking for someone to figure out why this is happening. I want my category page to display the posts in that category. Below you can view the image of the code I have. For some reason, it is displaying all of the posts, not just posts specific to that category.

    [​IMG]

    Any suggestion is appreciated.
    Tom
     
    launchplanet, Oct 2, 2009 IP
  2. manjobanjo

    manjobanjo Guest

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    why don't you search for an appropriate plugin which can help this function.
     
    manjobanjo, Oct 2, 2009 IP
  3. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #3
    I'm not a specialist in WP , but is this correct
    
    $recent = new WP_Query('showposts=10');
    
    PHP:
    Don't you need to specify category ID or name as a param for WP_Query?
    Take a look at http://codex.wordpress.org/The_Loop
    
    // Get the last 10 posts in the special_cat category.
      <?php query_posts('category_name=special_cat&showposts=10'); ?>
    
      <?php while (have_posts()) : the_post(); ?>
        <!-- Do special_cat stuff... -->
      <?php endwhile;?>
    
    
    PHP:
     
    AsHinE, Oct 3, 2009 IP
  4. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #4
    you could also just use the query string that is also provided by wordpress.

    
    $recent = new WP_Query( $query_string . '&showposts=10' ); # if $query_string is empty, it shouldn't be on category.php, it'll simply ignore the first ampersand
    
    PHP:
     
    ansi, Oct 3, 2009 IP