I'm running some template files outside of the actual theme and I am displaying some posts on this templates. Everything worked absolutely fine but some days ago (maybe the update to 4.5) the default settings of WordPress started to override my posts_per_page=-1 and I have no clue why this is starting. (No new plugins installed)

    // Include WordPress
    define('WP_USE_THEMES', false);
<?php while (have_posts()): the_post(); ?>
    <section class="in_tab">
        <figure class="tab_fig">
            <?php the_post_thumbnail('thumbnail'); ?>
        <h2><?php the_title(); ?></h2>
        <a class="insidelink" target="_blank" href="<?php the_permalink(); ?>" >Weiter...</a>
<?php endwhile; ?>
  • I don't see any changes to inline documentation for it and it would be extremely unlikely for WP to change existing argument.
    – Rarst
    Apr 23, 2016 at 9:50
  • check the error_log and post its output :) Apr 23, 2016 at 10:00
  • the only error i get is: [23-Apr-2016 10:16:25 UTC] PHP Notice: WP_Query wurde mit einem Parameter oder Argument aufgerufen, der seit Version 3.1 <strong>veraltet ist</strong>! „caller_get_posts“ ist veraltet. Bitte benutze stattdessen „ignore_sticky_posts“. in .../wp-includes/functions.php on line 3846 English version: WP_Query was uses an deprecated argument or parameter „caller_get_posts“ instead use „ignore_sticky_posts“
    – Steve
    Apr 23, 2016 at 10:17
  • pls excuse my scrappy english in the comment above :)
    – Steve
    Apr 23, 2016 at 10:34

2 Answers 2


Regarding my comment to Steve's answer, see also Override the default number of posts to show for a single loop? The "method" version of Steve's answer would be:

function limit_posts_per_archive_page( $query ) {
  if ( $query->is_post_type_archive( 'zitate-sprueche' ) || $query->is_tax('zitate-kats') || $query->is_post_type_archive('daten') || $query->is_tax('daten-kats')) {
    $limit = 27;
  } else 
    $limit = get_option('posts_per_page');
  $query->set( 'posts_per_archive_page', $limit );
add_action( 'pre_get_posts', 'limit_posts_per_archive_page' );

Similar code works for me.


I found the problem. Here is the solution in case someone stumbles upon a similar problem.

I had a filter in my functions.php that limited the showed posts on several custom taxonomies and the default value was set in the else statement

// Customizing posts per page on zitate archive 

function limit_posts_per_archive_page() {
if ( is_post_type_archive( 'zitate-sprueche' ) || is_tax('zitate-kats') ||   is_post_type_archive('daten') || is_tax('daten-kats')) {
    $limit = 27;
else if (is_post_type_archive( 'videos' ) || is_tax('videos-kats') || is_post_type_archive( 'whitepaper' ) || is_tax('whitepaper-kats')) {
    $limit = 9;
    $limit = get_option('posts_per_page');

set_query_var('posts_per_archive_page', $limit);
add_filter('pre_get_posts', 'limit_posts_per_archive_page');

I changed the else to

else {
// do nothing :)

Now it works as usual

  • Reading the inline docs above do_action_ref_array( 'pre_get_posts', array( &$this ) ) in wp-includes/class-wp-query.php, it's better to use the method variables.
    – kitchin
    Mar 30, 2019 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.