I’m building a site that has two custom post types: Auction and Lot. Lots are connected to an Auction via the post_parent field.
The single-auction.php template show 9 lots of an auction using the following query:
$args = array(
'post_type' => 'lot',
'posts_per_page' => 9,
'order' => 'ASC',
'post_parent' => $auction_id
);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query = new WP_Query( array_merge( $args, array('paged' => $paged) ) );
The pagination, though, doesn’t work. When I go to:
http://domain.com/auction/{auction-title}/page/{page-num}/
WP redirects me to:
http://domain.com/auction/{auction-title}/
Therefore I can only see the first 9 lots of an auction.
Any ideas about what could be happening? I think that this issue is related to permalinks. I suppose WP expects an URL like this to paginate lots:
http://domain.com/lot/page/{page-num}/
But this lists ALL lots.
Any help would be appreciated.
Thanks!
I managed to find a solution to my problem. Paste the following code into your functions.php file:
Can someone please tell me what the redirect_canonical filter does? I’ve read some people recommending against touching it.
Thanks