Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sorry for me, if I use incorrect words or sentenses, my English is poor, i.e. I'm from Russia. I have problem with pagination by using WP_query and pagination links like next_posts_link and previous_posts_link. My permalinks set is /%category%/%postname%/. WP 3.3.1. There is my code:

<?php
$paged = (get_query_var('page')) ? get_query_var('page') : 0;
$looks = new WP_Query('cat=3&posts_per_page=4&paged='.$paged);
while ($looks->have_posts()) : $looks->the_post(); ?>

    <ul class="look">
    <a class="look_thumb" href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">
    <?php the_post_thumbnail('medium'); ?>
    </a>
    <h2><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    </ul>
<?php endwhile; ?>
<?php next_posts_link('<small class="page_navi">Другие записи >></small>'); ?>
<?php previous_posts_link('<small class="page_navi">Предыдущие записи <<</small>'); ?>
<?php wp_reset_postdata(); ?>

next_posts_link and previous_posts_link don't apear on page. This custom loop from my template page: 'looks_page.php'. What's wrong!? I'm trying fix it problem by during 3 days, but no results :(.

share|improve this question
    
    
sorry, but all of your suggestions don't work. –  Timur Apr 10 '12 at 18:42
    
if neither of those work, then you've made an error in implementing them. what that error may be I can't say without seeing the code you've tried. –  Milo Apr 10 '12 at 18:52
    
    
$loop->max_num_pages should in your case be $looks->max_num_pages. –  Milo Apr 10 '12 at 20:26

1 Answer 1

Looks like you're using the wrong query_var. It should be 'paged'

$paged = (get_query_var('paged')) ? get_query_var('paged') : 0;
share|improve this answer
    
Also, make sure you have at least 5 posts in your category. –  joeljoeljoel Apr 10 '12 at 18:04
    
page is correct. see Pagination Note on WP_Query codex page‌​. –  Milo Apr 10 '12 at 18:11
    
WP Codex:Pagination Note: You should set get_query_var( 'page' ); if you want your query to work with pagination. Since Wordpress 3.0.2, you do get_query_var( 'page' ) instead of get_query_var( 'paged' ). The pagination parameter 'paged' for WP_Query() remains the same. –  Timur Apr 10 '12 at 18:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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