Skip Navigation

[Resolved] Related posts filtered by taxonomy

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)

This topic contains 23 replies, has 2 voices.

Last updated by Minesh 1 year ago.

Assisted by: Minesh.

Author
Posts
#2674633

I am trying to use a Legacy View in different pages, to show a slider with related posts (from the same custom post type). The posts are related via a custom taxonomy.

I have been following this guide: https://toolset.com/documentation/legacy-features/views-plugin/filtering-views-by-taxonomy/ and this support thread: https://toolset.com/forums/topic/link-inside-post-type-to-other-post-of-the-same-type/, but I haven't been able to make it work. The posts that appear in the slider are not the correct ones.

What is the link to your site?
hidden link Here, one post should appear in the slider, but it shows no results. (the sliders are at the end of the pages)
Here hidden link the slider should show 3 posts (the ones selected in the taxonomy:hidden link), and instead is shows 10.

These are the view settings: hidden link

What am I doing wrong?

#2674675

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Can you please share admin access details and let me review that how you configure the view?

*** 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.

#2674737

Minesh
Supporter

Languages: English (English )

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

Can you please check now and review that you get correct result now.

I've uncheck the checkbox setting "Don't include current page in query result" on your edit view page:
- hidden link

#2674775

Well, now it's a bit worse than before really: I am getting the same wrong results as before, only now also the current post is showing in the slider - and I don't want that, that is why I had "don't include current page" checked...

#2674797

Minesh
Supporter

Languages: English (English )

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

When I checked the following page: hidden link

On edit page I can see the term assigned to this post is "AE-MP" for taxonomy "Autoclaves relacionadas".
- hidden link

We can set the taxonomy filter to:

Autoclaves relacionadas the same as the page where this View is shown

When I checked the "AE-MP" it has assigned only one post and that is the same post where you claim that it should display only 1 result.
- hidden link

It will display the 1 result if you uncheck the checkbox setting "Don't include current page in query result" because its the same post where you assigned the term "AE-MP". If you keep checked the setting ""Don't include current page in query result"" then it will not display the result that is the same post.

Actually - its showing the correct result as per the settings you set. Try to assign the term "AE-MP" to another post and you should see that post on the following post: hidden link

#2674809

The product "AE-MP" (hidden link) has assigned the post "TLV-MP" in the "autoclaves relacionadas" taxonomy, and that is the only product that should appear in the slider. Instead, it shows 6 posts that have no relationship with AE-MP within the "autoclaves relacionadas" taxonomy.

If I uncheck "Don't include current page in query result", I still get the 6 wrong product, plus the AE-MP itself...

The page hidden link instead, is the page for the product "TLV-MP". It has "AE-MP" assigned in the taxonomy, and that is the product that should appear in the slider. Instead, the slider is empty. I I uncheck "Don't include current page in query result", I get one product in the slider, which is the product TLV-MP: the wrong one, since it's the current page, while the slider should show product "AE-MP" instead...

#2674813

Minesh
Supporter

Languages: English (English )

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

It seems you misunderstand how filter works here.

If you set your view to query taxonomy "Autoclaves relacionadas" where the page is displayed.

For instance - for this post: hidden link

For the above post the term assigned is "AE-MP" for the taxonomy "Autoclaves relacionadas" :
- hidden link

To your view - you added the query filter to filter posts for this view:
- hidden link

Taxonomy Query Filter added:

Select posts with taxonomy:
Autoclaves relacionadas the same as the page where this View is shown

- That means the query filter try to fetch the terms assigned to currently displayed post for the taxonomy "Autoclaves relacionadas" that is why if you load the following post:
- hidden link

It will filter and show results only for the terms "AE-MP" because for the above post the term assigned is "AE-MP".

I hope you are getting me now.

It seems you want to involve here another taxonomy - doesnt it?

#2674817

I am afraid I am not following you.

For the hidden link post, the term assigned in the taxonomy is AE-MP, that is correct.

Then, if the query filter try to fetch the terms assigned to currently displayed post for the taxonomy "Autoclaves relacionadas", the post hidden link shouldn't the results be for the terms AE-MP?

The only result it shows is TLV-MP...

Is there any other way to achieve what I need?

That is, for the slider to show the products selected in the "autoclaves relacionadas" taxonomy
In the hidden link example, it should show this post: hidden link

#2674949

I think I understand the way the filter works, and unfortunately it's not the way I need, so I wonder whether there is a different way to achieve the result I am looking for.

I see that if I choose a taxonomy as a filter, the results display all the product that share the same taxonomy.

Instead, I need a way to pick, from each post edit page, the other posts I want to appear in the slider, that will be different for each page

Is there a way to do that?

#2674951

Minesh
Supporter

Languages: English (English )

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

There is no dynamic or Artificial Intelligent available - we have to mention what posts you want to display and when.

Do you have any other field/taxonomy where we compare against the current post taxonomy term and if those are match then we can display the result?

#2674971

As I previously said, we do have to mention the posts: the ideal would be to mention them from within each post. Like, having a list of the other posts to select from.

I cannot mention the posts from the view, since the view is used on a dynamic template that is used for all the posts from the same custom post type, and the slider should show different results on each page.

And creating one view for each post and then "mention" the posts from within the view would make the system difficult to manage, (the website will be translated into 5 languages)

I find difficult creating another field/taxonomy to compare since the relationship among the posts is not equal: for instance, it happens that post B must appear on post A slider, but post A doesn't have to appear on post B... That is what is making it difficult

#2674991

Minesh
Supporter

Languages: English (English )

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

Unfortunately there is no such dynamic way that system can understand automatically that X post should be shows on Y page without mentioning.

Maybe you can add a custom field that should hold the post ID and those post IDs we can display for slider on said post.

#2675015

Following your advice, I am trying to create a custom field group to then add the posts id, but I am not sure which is the way to go.

I thought the way to go was choosing "post reference" as field, but there is no way to connect the same custom post type with itself. like i cannot create a relationship many-to-many within the same custom post type, and I think that is exactly what I am trying to do: establishing a many to many relationship among posts of the same type...

#2675017

Minesh
Supporter

Languages: English (English )

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

I suggest to add custom number field.
- You can store the comma separated post ids to it
or
make this field repeating field so you can store one number per number instance.

What is your choice?

#2675025

I'd be ok with either of them.
Is there one that makes it easier to work with in the view?

Or it is exactly the same