0
votes

I am trying to create a custom pagination at the end of a category page and it all works fine, except that I have created a custom post type and when I publish custom posts, the pagination total post count only counts the number of normal posts in the category, so you don't see all the posts in the pagination.

And I realised that it's happening here:

global $wp_query;
$post_count = $wp_query->found_posts;
var_dump($post_count); // number doesn't include published custom posts

How can I make the wp_query->found_posts value also include custom posts published so that the pagination doesn't miss any posts?

1

1 Answers

0
votes
$count_posts = wp_count_posts('your-post-type');
$total_posts = $count_posts->publish;
echo $total_posts . ' custom posts. ';