If you check the documentation for WP_Query
you will notice that post_count
, which you are using, returns the number of posts being displayed. That is what you see, but not what you want. found_posts
returns the total number of results for the query, which is what you want.
$post_count
The number of posts being displayed.$found_posts
The total number of posts found matching the current query parameters
Note that if your query runs with 'no_found_rows' => true
the found_posts
value will be 0, and there is a found_posts
filter that can effect the result as well.
Related Posts:
- Count posts within a custom post type and specific taxonomy and terms?
- How to Display a List of Users Who Have Made at Least 1 Post?
- Including categories in search results
- How to Display Network Post Count?
- Search Custom Post Type Pages and Custom Fields in 2 Dropdowns?
- How to cache a shortcode functions output?
- Display all search results
- Count posts in category including child categories
- Search posts by post author name
- Search not working with title and content
- Count singular post views automatically
- how to hide specific post from google search
- Network wide post count (WP Multisite)
- Redirect based on user post count
- Alternate custom content in the loop
- How to search only by post title and category?
- Pagination not working on custom query
- Show that current post is number X out of X
- How can I get all posts data from within a paginated search result?
- Search query – exact post title match
- Double count view in archive.php
- pagination hook doesn’t work with search results
- Search for posts based on their url in the admin?
- Count to how many categories a post belongs to
- wp_query ‘s’ parameter does not work with custom post type
- Differentiate between posts and pages in search results
- Count total number across post types
- How to hide first gallery for every post?
- Private Posts/Pages & Search
- Display number of posts via adress bar?
- Tags to Post-ID mysql query. Tag Search
- How to change wordpress dates to native language (even if the languge not available i wordpress)
- Counter of posts ever posted – even deleted ones
- Display Published Posts Count for Certain Time Period
- How can I get global $post to work for CPT and update user?
- How to filter my search in post if contains a word in title, content or excerpt?
- Search results posts_orderby and ID
- Posts and Attachments with “Published” status in Search
- How do I change the core post search algorithm? Where is it found/constructed?
- Display Notification Bar on Header on Certain Post Count
- Show posts count for Categories and Tags in wp_nav_menu
- How to add category post count in main navigation menu [closed]
- Count number of posts of current month
- Howto show comment count by post in post?
- Counter is skipping post when I still want it visible [closed]
- How to add add more properties to WP_Post object in search results loop
- Total number of posts in query (category/tag/author/search results/main page…)
- See if a post has a specified tag
- Count several post tags
- How do I insert a after every 5 posts in a WordPress Loop that infinitely loads posts?
- Count the number of a post types associated with another post type
- Echo the number of posts being displayed
- Display amount of pending posts in back/front end
- Why does WordPress search returns same number of results for every search query?
- Hide parts of the post content after typing it’s name or searching it by category
- search content of pages and list in wp-admin
- How to exclude the word “class” from being matched in search?
- Count user posts and store the number for later use
- why the posts queried from sql is more than those showed on the page?
- Will multiple category descriptions effect my search engine optimization?
- What would causes search to return incorrect results?
- I want to add another search box on posts page in dashboard
- Count the total views of all user posts published
- Showing Posts if non are found
- search form for custom fields
- Author post count in category
- How to show posts in grid style on search result page?
- Set post title font size automatically according to number of words in post title
- Search results with pagination not working
- How to show only homepage in google results instead of privacy, contact pages
- Redirecting wordpress search query to archive page
- How to create custom search form function including post “tags”
- Remove pagination if search returns empty
- Show post count in custom taxonomy page
- Count singular post views automatically
- How to count posts in tags within time limit
- How do i search post by jquery datepicker?
- How to get value of a selected option from select tag and use it in WP_query to filter posts?
- Display Custom Post Category Count & WordPress Category Count Using Shortcode
- Counting Posts by Category
- show only one category and filter by tag
- Display number of post published every day
- Alternative content between posts no repetition
- count_posts to a standalone link
- Find post tags words in post content and link them to tag URLs
- Custom author search
- How to control Post view count incresing in sidebar widget posts too?
- WordPress search for specific Post Type
- Display result of custom form
- Customize search results to include custom posts and display in a specific template page
- How to mark every 3rd post
- Add a minimum word count to Excerpt (and how to force Excerpt as a rule for WyPiekacz)
- Custom Post Title as search term
- Related posts by searching post tags of single post as terms
- How to limit the number of posts a user can publish based on user type
- ho can I get the number of the current post instead of the post id?
- post_count not working
- Adding Count Post in Page
- How to get only post=’product’
- Display post count on archive page in reverse order