Support » Fixing WordPress » Issue with posts_per_page & category combination

  • Been struggling with this for a few hours now, I hope I’m not overlooking an older topic about this or anything.

    What I want to do is fairly simple actually

    I just want to show one post of a specific category. I’m using this code.

    // the Loop
    while (have_posts()) : the_post();
    the_content('Read the full post ยป');

    Now, both ‘cat=3’ & ‘posts_per_page=1’ work perfectly fine, but when using them in combination the posts per page limit just won’t work. (While the cat-part still does its job)

    I have also tried ‘showposts=1’, which again works separately but not in combination with the ‘cat=3’

    Thanks for taking the time!

Viewing 13 replies - 1 through 13 (of 13 total)
  • Example of proper pagination:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat=1&posts_per_page='.get_option('posts_per_page').'&paged=' . $paged);

    But how do I specify now that I just want it to show 1 post?

    And any explanation why they work separately but not when used together.

    Thanks for the quick reply!

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat=3&posts_per_page=1&paged=' . $paged);

    Thanks, I figured that was what you meant and already tried that but it seems to give the exact same result as before. Works without the cat=3 but not in combination with it … Thus the posts_per_page seems to be ignored … any ideas on what may be the problem?

    Look at the WordPress Default theme’s wp-content/themes/default/index.php and make sure you are using the correct structure for using the template tag, previous_posts_link() and next_posts_link().

    Related plugin:

    edited: thought it worked, but was mistaking

    Everything seems to work perfectly as expected. But every time I try using both cat=4 and posts_per_page, the category just gets ignored. I’ve tried about everything by now … Any idea on what the problem may be?

    (Don’t think it would matter, but I am using the Carrington framework)

    the help is much appreciated

    I get the same problem. and im using Carrington as well, so that must be the real problem lol

    If you are still struggling with this problem, I have a solution for you. I am using the Carrington theme as well and can confirm this is a bug with the theme.

    If you look in carrington-core/ajax-load.php on line 88, there is a function which overrides the posts_per_page parameter when you’re trying to call query_posts with a category. You can remove this filter completely with the following:

    remove_filter('pre_get_posts', 'cfct_posts_per_archive_page');

    At that point, everything should work for you again.



    where do you type that? In the ajax-load file or in the index?



    Sorted it, now have

    remove_filter(‘pre_get_posts’, ‘cfct_posts_per_archive_page’);

    I am having this same problem. I built my own theme based off of the default theme files. Does anyone know of a reason this wouldn’t work using the default theme? I looked for something like what was mentioned above, but couldn’t find anything.

    Thanks your help. I wasted my 5 hrs to sort this out.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Issue with posts_per_page & category combination’ is closed to new replies.