Skip Navigation

[Resolved] Display posts count for a view on the index page

This support ticket is created 5 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
- 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/Karachi (GMT+05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by Jeffrey 5 years ago.

Assisted by: Waqar.

Author
Posts
#1229820

Hello, some times, I would like to display a view title with a link and posts count linking to post view on an index page, I know I can use [wpv-items-count] to show the post count found. but if so, I have to create tow view, one for showing the posts list, another one for showing posts count, and then put it on the index page.

Can I have a way to reuse the same view and modify some parameter to achieve that? Such as the example below

My published post 15------------------------- the view link with the item count

point this link to the my published post.

I consider this is a very common request, but I don't know why I can not find a answer in the forum.

Thank you so much!

#1229932

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Jeffrey,

Thank you for contacting us and I'll be happy to assist.

To generate two different outputs from a single view, you can use an attribute value, passed through the view's shortcode.
( https://toolset.com/documentation/user-guides/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes )

You'll first create a view with a full output ( i.e. posts list ). Once it is ready, you can split the contents of the "Loop Editor" section into two conditional blocks.
( ref: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/ )

1. The first block will only show when "version" attribute in the view's shortcode will be set with the value "short".


[wpv-conditional if="( '[wpv-attribute name="version"]' eq 'short' )"] 
<p>The count of posts is: [wpv-items-count].</p>
[/wpv-conditional]

2. Right below the first block, the second block will show when "version" attribute in the view's shortcode will not be set with the value "short".


[wpv-conditional if="( '[wpv-attribute name="version"]' ne 'short' )"] 
[wpv-layout-start]
......
[wpv-layout-end]
[/wpv-conditional]

Please note how the whole content of this "Loop Editor" section ( starting from [wpv-layout-start] to [wpv-layout-end] ) is nested/wrapped inside this second conditional block.

As a result, when you'll need the full output of the view, you'll use the regular shortcode:


[wpv-view name="slug-of-the-view"]

And when you'd like to show the short version, you'll include a shortcode attribute version="short":


[wpv-view name="slug-of-the-view" version="short"]

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1232123

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.