Skip Navigation

[Resolved] Show how many posts in a archive, and status of specific custom field.

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

Problem:
Display how many posts exist with some custom field value set. The number of posts, not the posts themselves.

Solution:
Create a View to query the post type in question and include a Query Filter to limit results to those with the required custom field value.

In the output section, don't include anything between the wpv-loop tags (which is output for each post). Immediately after the wpv-items-found shortcode insert the wpv-found-count shortcode which outputs the number of posts. In the wpv-no-items-found section output a zero.

You will want to disable the wrapper div.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-found-count

This support ticket is created 5 years, 7 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by samuelH 5 years, 7 months ago.

Assisted by: Nigel.

Author
Posts
#1265131
Skjermbilde 2019-06-11 kl. 11.49.38.png
Skjermbilde 2019-06-11 kl. 11.44.51.png

Hi,
I am building a site with about 10 different post types. On the frontpage I would like to indicate how many posts are published in the different post types. This info will be displayed inside a "info-container" on the front page.

I.e: Post type A has now 4 published posts. Furthermore I would like to show witch of these 4 posts that has been marked as "Finished" (Custom field - radio button) and witch posts that needs attention.

If possible it Would be fantastic if I also could show the numbers inside a icon of som kind.

#1265341

Nigel
Supporter

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

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

I'll leave it to you to work out how to style the output to your liking, but you can display the number of posts (filtered by some field value) using a View.

So create a View to display the number of posts of type A. The content selection will be type A. You'll want to add a Query Filter to only include posts where the custom field value is "Finished".

Now, in the output section, you won't output any fields from the posts, you will instead add the wpv-found-count shortcode immediately after the wpv-items-found shortcode (leaving the wpv-loop tag section blank). In the wpv-no-items-found section you'll want to output a zero.

You can include HTML markup to add icons etc., just note that the wpv-found-count shortcode itself will just output a number.

You can make as many Views as you need to do something similar for other post types etc.

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-found-count

#1265781

Hi Nigel.
This is great!.. But this part I dont understand fully:

"Now, in the output section, you won't output any fields from the posts, you will instead add the wpv-found-count shortcode immediately after the wpv-items-found shortcode (leaving the wpv-loop tag section blank). In the wpv-no-items-found section you'll want to output a zero."

Could you help me out with screenshot or simular?

#1265853
Skjermbilde 2019-06-11 kl. 21.45.47.png

Hi again,
This is now solved!

But I need to remove the default text when there is no items. See image

#1265881

My issue is resolved now. Thank you!