Weird WordPress Problems

Discussion in 'PHP' started by riteshsanap, Feb 26, 2012.

  1. #1
    Hello,
    My problem are that when ever i pass a query it shows one post extra then limited, here's the code
    
    <?php query_posts('cat='.$catnip2.'&order=DESC&orderby=date&posts_per_page=3');
    if (have_posts()) : $count = 0; 
    while(have_posts()) : the_post(); $count++; 
    $postimg = post_thumbnail_wpden();
    ?>
    <!-- HTML Loop Data Here -->
    <?php  endwhile; endif; wp_reset_query();  ?>
    
    PHP:
    so according to this code it should only show 3 posts, but its showing 4 posts, and also in some of categories were the posts are then also the query is not showing their posts any idea ?
     
    riteshsanap, Feb 26, 2012 IP
  2. geforce

    geforce Active Member

    Messages:
    173
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #2
    Have you tried changing the $count variable to 1 instead of 0? That should limit it to just 3.
     
    geforce, Feb 28, 2012 IP
  3. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #3
    yes tried it, but still the same
     
    riteshsanap, Feb 28, 2012 IP
  4. wpfan

    wpfan Member

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #4
    Have a look at wordpress custom queries docs for a better way to limit posts
     
    wpfan, Feb 28, 2012 IP
  5. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #5
    i already looked up to WP Codex, but i just hate this problem, everything was going fine, but it completely messed up when i imported a XML , from WordPress.org that has dummy data
     
    riteshsanap, Feb 28, 2012 IP
  6. furqanartists

    furqanartists Well-Known Member

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    101
    #6
    Use this! It will helps you

    <?php query_posts('cat='.$catnip2.'&order=DESC&orderby=date&showposts=3&ignore_sticky_posts=1');?>
    PHP:
     
    furqanartists, Feb 28, 2012 IP
  7. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #7
    not working :(
     
    riteshsanap, Feb 28, 2012 IP
  8. furqanartists

    furqanartists Well-Known Member

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    101
    #8
    is there any post published as sticky in this category?
     
    furqanartists, Feb 28, 2012 IP
  9. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #9
    well, yes but even after using your code

    ignore_sticky_posts=1
    PHP:
    it is not going
     
    riteshsanap, Feb 28, 2012 IP