Skip Navigation

[Closed] Shortcode to count posts

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.

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 9 months, 2 weeks ago.

Assigned support staff: Nigel.

Author
Posts
#1402541

Hi,
I have a job website where publishes job news as custom job posts. With the help of your support team, I have created one page that filters out the job posts based on another post-relationship. See the page here: hidden link
Now I want a shortcode to count the no. of posts on this particular page.
And also the Grand total of the 'Total No. of Vacancies' (these are also created with shortcodes) in those posts (See the screenshot).

Please help. Thank you.

#1402903

Nigel
Supporter

Languages: English (English ) Spanish (EspaƱol )

Timezone: Europe/London (GMT+01:00)

You can display the count of how many posts are returned by a View with the wpv-found-count shortcode: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-found-count

Insert that in the Loop Editor section of your View where you want the count to appear.

Regarding the Grand Total, this is rather more complex than displaying the sum of field values from a repeatable field group for a single post.

If you wanted to display this total towards the bottom of the page, at the end of the View and as long as there was no pagination involved, it wouldn't be too difficult to come up with a solution.

If you want to display the total towards the top of the page before the View output then that involves a more complex query that effectively recreates the View, iterates over the matching posts, gets the count for each individual post in a manner similar to the custom shortcode provided previously, and then sums those.

But that's well outside of support, you would need to hire a developer for that if you are not able to adapt that existing code yourself.

The topic ‘[Closed] Shortcode to count posts’ is closed to new replies.