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.

I have created a query which work correctly and displays the pagination correctly. However when clicking the links /products/category/application-range/page/2 the page will load and go back to /products/category/application-range/ rather than page 2, is there any reason why?

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
  'connected_type'      => 'product_to_category',
  'connected_items'     => $post,
  'posts_per_page'  => 10,
  'paged'           => $paged,
  'post_parent'     => 0,
  'orderby'         => 'menu_order',
  'order'           => 'ASC'
);

$products = query_posts($args);
share|improve this question
1  
Probably this. –  toscho May 22 '13 at 15:46

1 Answer 1

Perhaps you can take a look at this question and the answers and check if you really want to use query_posts() as it is not recommended while dealing with posts pagination. Why not use pre_get_posts action instead? Or you can try something like this:

<?php

    $custom_query = new WP_Query(array(
        'post_status' => 'publish',
        'post_type' => 'products',
        'connected_type' => 'product_to_category',
        'connected_items' => $post,
        'order' => 'ASC',
        'order_by' => 'menu-order',
        'posts_per_page' => '10',
        'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1
    ));

?>
share|improve this answer

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.