If I’m reading the documentation correctly, depending on what version of WP you’re using, it should be ‘page’, not ‘paged’.
From the documentation on wp_query:
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.
Thread Starter
OrT
(@ort)
I’m on the latest version.
Changing to page also breaks the query.
$temp = $wp_query;
$wp_query= null;
$paged = (get_query_var('page')) ? get_query_var('page') : 0;
$args=array(
'post_type' => 'Nieuws',
'paged' => $paged,
'posts_per_page' => 2,
'order' => 'desc'
);
$wp_query = new WP_Query($args);
You do not need the line:
$paged = (get_query_var('page')) ? get_query_var('page') : 0;
If I am right WordPress will populate and return the $paged variable in the query, so you do not need to set it.
$args=array(
'post_type' => 'Nieuws',
'paged' => $paged,
'posts_per_page' => 2,
'order' => 'desc'
);
$wp_query = new WP_Query($args);
HTH
David
Thread Starter
OrT
(@ort)
David, thanks for your time.
Same deal as before, the pagination is shown but /page/2/ throws back a 404 error.
Thread Starter
OrT
(@ort)
Extra: htaccess is fine, /%category%/%postname%/ is the permalink structure.
Hi,
I have tested this with this testing twenty eleven child theme, I added the code below as a template page to display the custom post types of ‘information’ with pagination and it worked file.
The template page code: http://pastebin.com/T257N6qW
Note:
My URL shows as ?page_id=61&paged=2, so yours is missing &paged=
Changed my permalink structure /%category%/%postname%/ (/page/2/) and I do not get the same error as you!
Pagination works fine!
HTH
David
Just looking at your pastebin again and you are using the plugin wp_navigate, have a look in the twenty eleven theme at the functions.php and the function twentyeleven_content_nav
It uses these variables and calls to return the output:
global $wp_query;
if ( $wp_query->max_num_pages > 1 ) :
previous_posts_link()
next_posts_link()
endif;
also try wp-pagenavi as I know this works with pagination as I use it on my website, so you can see it working.
HTH
David
Thread Starter
OrT
(@ort)
I’m using wp_paginate() actually, which is working fine on a number of other sites I’m running.
Hi,
I adjusted my pastebin and tested with the plugin wp-pagenavi and it worked fine.
http://pastebin.com/RPcsx1iy
I then downloaded and activated wp-paginate changed the template code and that also worked fine, so both work with custom type pagination and your permalink structure,
Screenshot of pagination
Not sure what is going on, can you pastebin the whole page code!
David
Thread Starter
OrT
(@ort)
Update: for reasons unknown, I’ve managed to get it working.
New problem: all other queries on /page/* are broken.
Even if I put their queries in a separate object and reset the variables:
$temp = clone $wp_query;
$wp_query = null;
...
<?php $wp_query = null; $wp_query = clone $temp; ?>
<?php wp_reset_postdata(); ?>
<?php wp_reset_query(); ?>
Thread Starter
OrT
(@ort)
David – my guess is the ‘Types’ plugin was causing the problems. Fiddled around with it, reactivated it, and suddenly the posts appeared.
Does that mean the topic is resolved?
David
Thread Starter
OrT
(@ort)
According to the title of the thread, I believe it is.
For the next problem I should open a new one that’s relevant.
Thanks very much for your assistance, David!
Mucht appreciated.