• Hello!

    I have custom post type called recipes and I created template “archive-recipes.php”.

    It works normally until I change number of posts:

    <div id="content">
    
    <?php if (have_posts()) { ?>
    	<?php global $query_string; ?>
    	<?php query_posts($query_string . '&posts_per_page=2'); ?>
    	<?php while(have_posts()) { the_post();?>
    
    		<div class="post">
    		    <h2><?php the_title(); ?></h2>
    		</div>
    
    	<?php } ?>
    <?php } ?>
    
    <div id="pagination">
    <div class="next-posts"><?php next_posts_link('? Older Posts') ?></div>
    <div class="prev-posts"><?php previous_posts_link('Newer Posts ?') ?></div>
    </div>
    
    </div>

    Does anyone has idea what is wrong there?
    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello radojica,

    Please try by removing the ‘$query_string’ parameter from your query_posts.

    Thanks

    Thread Starter radojica

    (@radojica)

    Thanks for suggestion, but if I do that I will get posts instead of recipes.

    Hello radojica,

    Remove ‘$query_string’ and just add single parameter post_type=”recipes”.

    Thanks

    Thread Starter radojica

    (@radojica)

    $query_string needs to be there but I tried as you suggested and it didn’t helped.

    I sorted problem with function that I added in functions.php

    but I still do not understand why this query doesn’t work!?

    Problem is related with settings for number of posts per page.
    it is set to 9.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Archive template doesn't work after changing number og posts’ is closed to new replies.