I have this code:
<?php $q = new WP_Query(array(
'post_type' => 'oferty'
));
?>
<?php while ($q -> have_posts()) : $q -> the_post(); ?>
<!-- .post | id: <? echo $post->ID; ?> -->
<article <?php post_class() ?> id="post-<?php the_ID(); ?>">
<div class="entry">
<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<small><?php echo get_field('bank'); ?></small>
<?php the_content(); ?>
</div>
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' ); ?>
<?php if($thumb) : ?>
<div class="bankimg" style="background-image: url('<?php echo $thumb[0];?>')"></div>
<?php endif; ?>
<div class="clear"></div>
</article>
<!-- /.post | id: <? echo $post->ID; ?> -->
<?php endwhile; wp_reset_query(); ?>
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
It uses wp_query
to list all the posts from post type oferty
. I set in WordPress options limit of posts to 2 and it works – but no pagination shows up. I tried WP PageNavi, WP Pagination and normal WordPress’ prev/next linsk.
Take a look at the pagination parameters when querying for custom post types:
https://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters
Specifically, try this: