• Hi there!

    There’s something funny with the pagination in my archives.php… The pagination is displayed nicely at the bottom of my page. However, the get_pagenum_link() seems to return a pagination that looks like this:

    url.com?cat=1&paged=2

    but this gives me a “ERROR 404 – NOT FOUND“…

    if on the other hand I strip the “d” and try the url:

    url.com?cat=1&page=2

    it paginates just fine…

    My WP_Query looks like this:

    $args = array('post_type' => array ('post', 'customposttype', 'tag', 'taxonomy','page'),
    	'posts_per_page' => 16, 'paged' => get_query_var( 'page' ), 'orderby' => 'date', 'order' => 'DESC');
    WP_Query($args);

    Any inputs on how I could fix this problem?

    Regards,
    Mike

Viewing 8 replies - 1 through 8 (of 8 total)
  • Try $paged it is a WordPress global.

    $args = array(
    		'post_type' => array ('post','customposttype','tag','taxonomy','page'),
    		'posts_per_page' => 16,
    		'paged' => $paged,
    		'orderby' => 'date',
    		'order' => 'DESC'
    	);
    WP_Query($args);

    HTH

    David

    Thread Starter isay

    (@isay)

    Still the “ERROR 404 – NOT FOUND”…

    When reading about the WP_Query it’s a bit cryptic:

    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.

    I’ve tried a few options but still get the 404…

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
    		'post_type' => array ('post','customposttype','tag','taxonomy','page'),
    		'posts_per_page' => 16,
    		'paged' => $paged,
    		'orderby' => 'date',
    		'order' => 'DESC'
    	);
    WP_Query($args);
    Thread Starter isay

    (@isay)

    Still 404…

    Sorry, something fell off when I pasted into the post…
    my archives.php code says $all_posts_in_cat = new WP_Query($args); instead of just WP_Query($args);

    $all_posts_in_cat = new WP_Query($args); is fine.

    Can you paste your archives.php up to pastebin and add the link in a reply here.

    David

    Thread Starter isay

    (@isay)

    Ok, I posted my archives.php and pagination.php into pastebin….

    archive.php: https://pastebin.com/9gTbXBTH
    pagination.php: https://pastebin.com/fNpdguPe

    Thanks really much guys if you would take a look at this!

    I really appreciate it…

    //Mike

    Thread Starter isay

    (@isay)

    Any hints on this one??

    If I am on the archives page and click on the link to page 2 it seems as though that the query information is lost and I am presented the general posts.php template…

    In other words, WP seem to forget that I was in the archive view…

    Any help is appreciated!

    //Mike

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Pagination problems in archive.php’ is closed to new replies.