Skip Navigation

[Resolved] Output number of posts of a particular type published by current user

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

Problem:
How to display the number of posts of a particular type published by the current user (e.g. on their profile page).

Solution:
Create a View for the post type in question which has a Query Filter for the post author (equal to current user).

In the Loop Output section use the wpv-found-count shortcode like so to report the number of posts:

[wpv-layout-start]
    [wpv-items-found]
    <p>[wpv-found-count]</p>
    <!-- wpv-loop-start -->
        <wpv-loop>
        <!-- not outputting the posts -->
        </wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
    <p>0</p>
    [/wpv-no-items-found]
[wpv-layout-end]

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

This support ticket is created 7 years 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 2 replies, has 2 voices.

Last updated by alexanderN-5 7 years ago.

Assisted by: Nigel.

Author
Posts
#600688

Good afternoon. How can I deduce the number of posts of a particular user of a certain type of posts?

#600808

Nigel
Supporter

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

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

Hi there

You can create a View which returns the posts of a particular type for a particular author (e.g. the currently logged-in user) and in the output section, instead of displaying the posts themselves, use the wpv-found-count shortcode to output the number of matching posts: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-found-count

So create a View for the post type in question. Then add a Query Filter with a filter for the post author. Choose whichever value makes sense for your use case.

Then use the wpv-found-count shortcode in your Loop Output section like so:

[wpv-layout-start]
	[wpv-items-found]
	<p>[wpv-found-count]</p>
	<!-- wpv-loop-start -->
		<wpv-loop>
		<!-- not outputting the posts -->
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
	<p>0</p>
	[/wpv-no-items-found]
[wpv-layout-end]
#600974

Thank you very much. You helped me a lot.