0

What's the best way to display pagination on a custom post type archive page without a plugin? I tried paginate_links() didn't work.

I'm using a custom query and here's the code:

$args = [
    'post_type'   => 'on_my_mind',
    'post_status' => 'publish',
];
$omm  = new WP_Query($args); ?>

<?php if ($omm->have_posts()): while ($omm->have_posts()): $omm->the_post(); ?>
    <?php get_template_part('template-parts/content', 'on_my_mind') ?>
<?php endwhile; ?>
<?php endif; ?> 
<?php wp_reset_postdata(); ?>
  • what happened? no links? wrong pages? 404 error? – Michael Apr 27 at 18:08
  • No links. Nothing happened! Nothing showed, thus nothing to click at all. What do I do? – jeno Apr 27 at 18:13
  • 1
    are you using a custom query in your custom post type archive page? possibly just post the full code of the template. – Michael Apr 27 at 19:13
  • Yes I'm using a custom query and here's the code: $args = array( 'post_type' => 'on_my_mind', 'post_status' => 'publish' ); $omm = new WP_Query($args); ?> – jeno Apr 28 at 8:41
  • <?php if ($omm -> have_posts()): while ($omm -> have_posts()): $omm -> the_post(); ?> <?php get_template_part( 'template-parts/content', 'on_my_mind' ) ?> <?php endwhile; endif; ?> <?php wp_reset_postdata(); ?> <hr> <div class="cell small-12"> <?php $omm -> the_posts_pagination(); ?> <?php $omm->paginate_links(); ?> </div> – jeno Apr 28 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.