Skip Navigation

[Resolved] Displaying only one post from each taxonomy

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

Problem:
Displaying only one post from each different taxonomy

Solution:
You should try to add a view with shortcode attribute filter by your taxonomy and limit the view's output to 1.

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/displaying-only-one-post-from-each-taxonomy/#post-1246254

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/passing-arguments-to-views/#examples
=> https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/

This support ticket is created 5 years, 6 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Author
Posts
#1246252

Hi

I'm trying to setup a view with my events. I'd like to have only one event from each category (location) displayed ( so only 4 events to be displayed, each from different location ) ( hidden link ) Also I have this date filter not to display events older than today ( hidden link )

Is this possible

Regards

#1246254

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - the best way I would suggest is to add a view with shortcode attribute filter by your taxonomy and limit the view's output to 1.

For example:

[wpv-view name="view-slug" location="chicago"]
[wpv-view name="view-slug" location="boston"]
[wpv-view name="view-slug" location="replace-term-slug"]
[wpv-view name="view-slug" location="replace-term-slug"]

I think this is the best why to deal with your requirement.

More info:
=> https://toolset.com/documentation/user-guides/passing-arguments-to-views/#examples
=> https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/

#1246270

I'm not sure I follow. Shall I create 4 views for each location? I'm only allowed to enter one filter for the location - hidden link

Thank You

#1246281

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - you should create only one view and add the taxonomy filter and filter it by views shortcode attribute.
=> https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/
[See "Value set by View shortcode attribute"]

And then add the same view 4 times with the different location slug:
For example:

[wpv-view name="view-slug" location="chicago"]
[wpv-view name="view-slug" location="boston"]
[wpv-view name="view-slug" location="replace-term-slug"]
[wpv-view name="view-slug" location="replace-term-slug"]
#1246282

Yes, but I can only add one location - hidden link and I cannot save it ( hidden link ) although here it says I can separate the values using comma ( hidden link )

Thank You

#1246283

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - with the filter you shared, you do not need to add the location name but the shortcode attribute name.

For example:

[wpv-view name="view-slug" location="chicago"]

Here, shortcode attribute name is location so you need to add the location insetead of location names. Also, set your view to limit to 1 results only.

So, by adding the same view with different location slugs as given under, and each time view will display 1 results you will have 4 items with different locations.
[wpv-view name="view-slug" location="chicago"]
[wpv-view name="view-slug" location="boston"]
[wpv-view name="view-slug" location="replace-term-slug"]
[wpv-view name="view-slug" location="replace-term-slug"]

More info:
=> https://toolset.com/documentation/user-guides/passing-arguments-to-views/#examples

#1246286

I'm using slugs but same result - hidden link

#1246288

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you share problem URL where you added the view and access details?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1246303

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now. I've added the view two times, you can add as many times as you want
=> hidden link

I can see its working - I've also adjusted the filter value:
=> hidden link

Now, it prints table headers each time so you need to add table headers before you add the first view.

#1246421

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Is it resolved? 🙂

#1246439

Yes it is resolved. Thank you very much 🙂

#1246440

My issue is resolved now. Thank you!