Skip Navigation

[Resolved] Count number of posts in view

This thread is resolved. Here is a description of the problem and solution.

Problem:

[wpv-found-count] returns wrong result.

Solution:

The problem is abnormal, please check these:

https://toolset.com/forums/topic/count-number-of-posts-in-view/#post-1379529

Relevant Documentation:

This support ticket is created 4 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by larryL 4 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1378435

I would like to display how many posts in custom post type in one of my views. For example: I have a view called 'Defects' I would like to display 'Total Defects: {show number here}

Alternatively I would also like to be able to filter that by other fields in the CPT from the front end. So let's say the total was '10' a user could click the filter and select only 1 'project' and reduce that to '5' or whatever number remained.

At the momenet when I display the total it shows up twice: 2 2 and I cannot figure out why.

Please help!

Thanks!

#1378607

Hello,

It is possible to display total found count by the Views query with shortcode [wpv-found-count], see our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-found-count

Displays the total number of posts, users or taxonomies that have been found by the Views query. This value is calculated before pagination, so even if you are using pagination, it will return the total number of posts matching the query.

In most cases, we use it outsider Views loop, for example:

...
	[wpv-items-found]
Total Defects: [wpv-found-count]
	<!-- wpv-loop-start -->
		<wpv-loop>
...
#1378943

Yeah, I already did that. But it counts it wrong. That is why I put the ticket in.

#1379529

The problem is abnormal, please check these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2019, deactivate all custom PHP/JS code snippets, and test again

3) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL and view URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1380283

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.