Skip Navigation

[Resolved] List Unique Results Only

This support ticket is created 5 years, 7 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 11 replies, has 2 voices.

Last updated by Shane 5 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#1279759

Tell us what you are trying to do?

I need to only return unique results. Specifically, a taxonomy. I have a few results that are the same taxonomy and I don't need it to repeat.

I am currently using a View to filter posts. Those posts have a taxonomy on them. I want to return a list of taxonomies from all the posts just one time. So if two posts have the same taxonomy I only want that taxonomy to return once.

Is there any documentation that you are following?

Couldn't find any.

Is there a similar example that we can see?

Not really.

What is the link to your site?

Can be shared. But not necessary was the concept can be applied without the site.

#1279815

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Robina,

Thank you for getting in touch.

I'm not sure I understand.

Is it that you want to list out the first post of a taxonomy? So if Taxonomy A has 3 post and Taxonomy B and 4 posts, you only want to get 1 post from taxonomy A and only 1 from Taxonomy B?

Please let me know.

Thanks,
Shane

#1280999

Let me try to explain a bit better...

I have these posts and they have a taxonomy checked:

Post 1 (Taxonomy A)
Post 2 (Taxonomy A)
Post 3 (Taxonomy A)
Post 4 (Taxonomy B)
Post 5 (Taxonomy B)

Part One: List of Taxonomies Used.

If Taxonomy A has 3 posts and Taxonomy B has 2 posts then the results would be:

Taxonomy A
Taxonomy B

Part Two: List of posts that have taxonomy.

Generate a list of posts in that taxonomy:

Taxonomy A
- Post 1
- Post 2
- Post 3
Taxonomy B
- Post 4
- Post 5

I can two part two just fine, but I am having trouble getting part one to work.

#1281025

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Robina,

I see what you mean now.

So for Part A this will require you to create a Taxonomy view. This taxonomy view will list out your taxonomy term names and it will serve as the parent view for your child view with post.

Take a look at this link below. This should be able to guide you through this process.
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/#taxonomy-view-with-a-post-view-for-a-child

Thanks,
Shane

#1281297

Thanks.

For Part A, I need to filter the taxonomies that are showing. I think I wasn't totally clear.

My View is producing a list of posts and I'm filtering those by a custom field. If my taxonomy is a list of states then I want to take all the posts in my view and produce a list of all the states that are on those posts without showing duplicate states.

My View
Post 1 (Virginia)
Post 2 (Virginia)
Post 3 (Idaho)
Post 4 (Idaho)
Post 5 (Florida)

Taxonomy Results (Unique only)
Virginia
Idaho
Florida

Then my nested view would produce

Virginia
- Post 1
- Post 2
- Post 3
Idaho
- Post 4
- Post 5
Florida
- Post 6

...And so on.

Getting my filtered view to only show me unique taxonomy results is where I am stuck. It's showing me either all results or repeating results per post that my view found.

Let me know where I need to clarify further.

#1281971

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Robina,

I believe I understand what you. So you first want your taxonomy view to list the taxonomy terms and under each unique term you list the appropriate post.

Our documentation below will guide you through how to achieve this exact result.
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/#taxonomy-view-with-a-post-view-for-a-child
Thanks,
Shane

#1282289

Correct me if I am wrong...

I first want (1) a Post View, then I'll nest (2) a Taxonomy View (without duplicates), then I'll nest (3) a Post View.

Post View
- Taxonomy View
- - Post View

I can't get the taxonomy view to not show duplicates.

#1283263

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Robina,

Yes this is correct. I'm not sure why your taxonomy view is showing duplicates as it should just be listing out the taxonomy for the posts.

Unless in your post view you are listing out the taxonomies using the [wpv-post-taxonomy] shortcode.

Would you mind allowing me to have access to the page where you are working on this ?

Thanks,
Shane

#1283557

Shane,

Could be where I am putting it? Since I don't want the taxonomy to output with each post and just generate a list I've put it outside the loop.

Login creds sent.

#1284301

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Robina,

In order for the view to display the individual taxonomies relevant to the post it must be added to the view loop.

However ive removed the filter from the taxonomy view and it is now displaying 3 locations.

Please let me know if this is what you want.

Thanks,
Shane

#1286329
2019_07_08_07_26_00_Locations.png

We're getting closer I think.

The taxonomy should only represent what is on the list. So it needs to be pulling from what the view loop is returning (but not on each item, it should be a separate list), or we need to have it use the state filter.

You can see in my example that the taxonomy is showing more than what is on the list.

Could be that I am going about this all wrong so I am open to ideas that achieve this.

#1286459

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Robina,

I believe i understand this fully now. So you want your taxonomy view to filter based on the state that is selected.

Unfortunately that isn't possible and the view can only be filtered based on the current page that its on or the current post that is in the view loop.

So unless one of those 2 are met then it won't work.

Thanks,
Shane