Skip Navigation

[Resolved] Show Total Custom Posts Count

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

Problem:
How to display the total amount of posts found in a view?

Solution:
https://toolset.com/forums/topic/show-total-custom-posts-count/#post-614824

This support ticket is created 6 years, 9 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by theW 6 years, 9 months ago.

Assisted by: Beda.

Author
Posts
#614738

I am trying to:
Show the Total Custom Posts Count of the CURRENT LOGGED IN USER in a Layout.
The short-code below works perfect in the Custom Post Loop:

[wpv-items-found]

But on the Page layout it has no effect:
Here's my code:

<b>#[wpv-items-found]</b> <a href="<em><u>hidden link</u></em>">PROJECTS</a><br />

Link to a page where the issue can be seen:
hidden link

I expected to see:
A good example would be:

If user "A" Logs in and creates "3" Projects,
"# PROJECTS" would auto change to > 3 PROJECTS

If tomorrow user "A" Logs in and creates 1 more Project.
"3 PROJECTS" would auto change to > 4 PROJECTS

If next week user "A" Logs in and deletes all his Projects.
"4 PROJECTS" would auto change to > 0 PROJECTS

Instead, I got:
Just
# PROJECTS
No dynamic counter

#614824

Well, that shortcode works only in a View's Loop, and it outputs nothing itself.

To display an amount of posts created, that is not the ShortCode to use.
For this, you use wpv-found-count.

A View is needed, even if the View then is displayed thru a Layout at the end, but without View, these ShortCode's won't work.

The View should query the desired Post type.

Then, a Query Filter should be added to it:

Select posts with the author the same as the current logged in user.

The Loop of this View should look minimally like this:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
[wpv-found-count]
	<wpv-loop>

	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

After, this View can be inserted anywhere you want, also thru Layouts as a cell.

It will display only the number of posts found that this user authored.

[wpv-items-found] ShortCode will not return any numeric value.
This is a ShortCode to determine an area in the loop, not to output something:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-items-found

#617096

I see, thank you Beda