• My pagination links are failing for a custom post type here https://mjw.view-wireframes.com/about-us/press/

    the page reloads https://mjw.view-wireframes.com/about-us/press/page/2/ but this has no effect on the displayed posts. Flushing the permalink structure has no effect so my guess is the problem is in the query.

    <?php
    //$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query(array( 'post_type' => 'press',
                                    'orderby'   => 'post_date',
                                    //'showposts' => '10',
                                    'posts_per_page' => 10,
                                    ));
    while ($wp_query->have_posts()) : $wp_query->the_post();
    ?>
    
    <?php
        // The following determines what the post format is and shows the correct file accordingly
        $format = get_post_format();
        get_template_part( '/lib/includes/post-formats/'.$format );
    
        if($format == '')
        get_template_part( '/lib/includes/post-formats/standard' );
    ?>
    
    <?php endwhile;  ?>
    
    <?php if (function_exists("pagination")) {pagination($additional_loop->max_num_pages);} ?>
    
    <?php $wp_query = null; $wp_query = $temp;?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    try it with this:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $wp_query->query(array(
        'post_type' => 'press',
        'orderby'   => 'date',
        'posts_per_page' => 10,
        'paged' => $paged
    ));

    Thread Starter toomanyairmiles

    (@toomanyairmiles)

    Mate, I’ve spent 7 hours stuck on this, thank you so much. Could you explain where I went wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problems with pagination for a custom post type’ is closed to new replies.