Viewing 4 replies - 1 through 4 (of 4 total)
  • Working with Custom Post Types is best explained by the Developer of your Theme or if in use, the Child Theme. Have you discussed this with them? It can be fairly complicated. Since it matters first how a Theme does or does NOT do this, without knowing which theme is in use, we can only add a generic reply.

    Thread Starter WPWanderer

    (@wpwanderer)

    Basically, I got it to work just trying to understand why it works. This is for showing pagination for a custom post type and query.

    For the loop, I got the pagination to work for this:

    $wp_query = new WP_Query();
    $wp_query -> query($args);
    while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

    However, I couldn’t get this loop to work with pagination, which is pretty standard:

    $loop = new WP_Query($args);
            if($loop->have_posts()) :
            while($loop->have_posts()) :
            $loop->the_post();
            ?>

    Arguments are the same for both.

    What if you rename the second $args to something like $new_args
    Make sure you set the second args also to $new_args also.
    You likely will also want to reset WP_Query above the loop and look at the pre_get_posts filter also.

    wp_reset_query();
    $loop = new WP_Query($new_args);
            if($loop->have_posts()) :
            while($loop->have_posts()) :
            $loop->the_post();

    Thread Starter WPWanderer

    (@wpwanderer)

    Thanks. I will try it out. As I said, I got it to work. But I am finding ‘paged’ pagination on cpt’s and custom queries to be a bit funky, so just trying to get a good grasp of it.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Pagination with wp_query and cpt…’ is closed to new replies.