• I have the following problem:

    I have limited my “posts per page” on all category archive pages in the functions.php like this:

    add_filter('pre_get_posts', 'limit_category_posts');
    function limit_category_posts($query){
        if ($query->is_category) {
            $query->set('posts_per_page', 5);
        }
        if ($query->is_single()) {
            $query->set('posts_per_page', 50);
        }
        return $query;
    }
    
    add_filter('pre_get_posts', 'per_category_basis');
    function per_category_basis($query){
        if ($query->is_category) {
            if (is_category('26')){
                $query->set('posts_per_page', 2000);
            }
            if (is_category('27')){
                $query->set('posts_per_page', 2000);
            }
        }
        return $query;
    }

    This works fine so far. But now I have a single.php – file that reads posts from one category and displays these in a list, like this:

    <?php
      query_posts(array(
          'category_name' => $autorsuche,
       ));
    
       if ( have_posts() ) :
          echo '<br /><h3>Publikationen:</h3><br /><ul class="publications">';
       endif;
    
       while ( have_posts() ) : the_post();
    ?>
    
    <li><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
    <?php the_date( 'd.m.Y', '(', ')' ); ?></li> 
    
    <?php
       endwhile;
        echo '</ul>';
        wp_reset_query();
    ?>

    But this list is limited to 5 posts as well since the above filter applies as well. I need this to have a much larger or better no limit at all.

    I tried a lot to alter the filter in the functions.php but didn’t find a solution yet.

    Any help would be much appreciated!

    Thank you!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘WordPress limit posts per page’ is closed to new replies.