Skip Navigation

[Resolved] Post display based on count of Views

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.

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 2 months, 3 weeks ago.

Assigned support staff: Waqar.

Author
Posts
#2409867

Tell us what you are trying to do?

I have two post types : 1) zadanie and 2) dis
"dis" posts contain custom field "artel" with numbers
need to show post "dis" with "artel" field which number equal to number of posts "zadanie" posted by current author.

Example: I posted 10 posts "zadanie"
need to display "dis" post which "artel" field contains number 10.

Please advise how to do this with toolset?

Thank you in advance!
Sincerely
Anton

#2410689

Waqar
Supporter

Languages: English (English )

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

custom-field-filter.png
post-author-filter.png

Hi Anton,

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

To achieve this, you'll need two views created using the classic/legacy editor:

1. The first view will be set to show the 'zadanie' post type, with the post author query filter, to show only posts where the currently logged-in user is the author.
( example screenshot: post-author-filter.png )

We only need this view to return the number of 'zadanie' posts by the current user, so in the loop of the view, you'll only use the shortcode "wpv-found-count".
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-found-count

To avoid any extra spaces or characters from the view's output, please uncheck the option "Disable the wrapping DIV around the View" and also remove the shortcode "[wpv-filter-meta-html]" from the view's "Output Editor" section.

2. The second view will be set to show the 'dis' post type, with the custom field query filter for the "artel" field, where it is the number equal to the shortcode attribute "artel".
( example screenshot: custom-field-filter.png )

3. When both views are ready, you can use the shortcode of the first view, as the value of the "artel" attribute, in the shortcode of the second view, for example:


[wpv-view name="second-view" artel="[wpv-view name='first-view']"]

Note: Please replace "first-view" and "second-view" with the actual names/slugs of your views.

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

regards,
Waqar