0

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 :(.

5
  • see wordpress.stackexchange.com/questions/20424/…
    – Milo
    Commented Apr 10, 2012 at 17:31
  • sorry, but all of your suggestions don't work.
    – Timur
    Commented Apr 10, 2012 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
    Commented Apr 10, 2012 at 18:52
  • www65.zippyshare.com/v/65980174/file.html
    – Timur
    Commented Apr 10, 2012 at 19:41
  • $loop->max_num_pages should in your case be $looks->max_num_pages.
    – Milo
    Commented Apr 10, 2012 at 20:26

1 Answer 1

1

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

$paged = (get_query_var('paged')) ? get_query_var('paged') : 0;
3
  • Also, make sure you have at least 5 posts in your category. Commented Apr 10, 2012 at 18:04
  • page is correct. see Pagination Note on WP_Query codex page.
    – Milo
    Commented Apr 10, 2012 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
    Commented Apr 10, 2012 at 18:37

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.