Skip Navigation

[Resolved] filter with referenced post taxonomy

This support ticket is created 2 years, 10 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)

This topic contains 25 replies, has 3 voices.

Last updated by davidS-72 2 years, 9 months ago.

Assisted by: Shane.

Author
Posts
#2305871

Tell us what you are trying to do?
scenario:
I've a CPT A and a CPT B with a field witch is a CPT A post reference.

I want to do a view listing CPTs B posts filtered with the CPT A's (post referenced) taxonomy.

Can you help me please?

thanks,
David

#2306067

Shane
Supporter

Languages: English (English )

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

Hi David,

Thank you for getting in touch.

Unfortunately you won't be able to do this because you require that the post reference posts be prefiltered by the a taxonomy to then filter your posts.

Is your view going to be on the page that the post reference field is linking to ?

If so then we can filter by the post reference field as well as the taxonomy of the post.

Please let me know.
Thanks,
Shane

#2306641

Hi Shane,
OK, then how can we prefilter post reference posts by taxonomy?

thanks,
David

#2306689

Minesh
Supporter

Languages: English (English )

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

Shane is on Holiday today he will get back to work tomorrow, He will continue to help you tomorrow. Please standby.

You can build a custom search using the custom fields or taxonomy that belongs to post type you set your view to query.

Do you mean that you want to add a post reference field as filter and that post reference field you want to filter with specific term(s)?

#2307625

Shane
Supporter

Languages: English (English )

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

Hi David,

OK, then how can we prefilter post reference posts by taxonomy?

Unfortunately that won't be possible to do given that the how the Post Reference field filter works. There is also no public available API for you to filter reference field values.

Secondly this can be worked around by adding a taxonomy filter to the view as well. Is your view going to be filtered based on the current page where it is being displayed?

Please let me know.
Thanks,
Shane

#2311475

Hi Shane,
I don't undertand you, what exactly does the option "don't include the current page in the query result"?

thanks,
DAvid

#2311551

Shane
Supporter

Languages: English (English )

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

Hi David,

"don't include the current page in the query result"?

This option is to ensure that your view doesn't list out the current post that it is placed on.

Let's say you create a Post Type A and you created posts in that post type.

Now you've created a view that will list Posts Type A and added it to the template for Post Type A.

This view should list all the posts except the one currently being viewed. With this setting that current post will be excluded from the list.

Thanks,
Shane

#2312089

OK Shane,
the answer to "Is your view going to be filtered based on the current page where it is being displayed?" is NO.

Then, is there some way to do "I want to do a view listing CPTs B posts filtered with the CPT A's (post referenced) taxonomy." ?

thanks,
David

#2312287

Shane
Supporter

Languages: English (English )

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

Hi David,

<Em> "I want to do a view listing CPTs B posts filtered with the CPT A's (post referenced) taxonomy."

No there is not. You can filter by the post reference field but not the taxonomy that the post is attached to.

Thanks,
Shane

#2312401

OK. Thank you!

#2312443

Hi shane,
it's me again 🙂
I've changed the CPT A's (post referenced) taxonomy for an select field.

Then, when in the view I filter CPTs B posts by CPT A's (post referenced) select field, this appears in the filter options and all seems to be fine, but doesn't works (don't display any post).

Is it normal?
David

#2312533

Shane
Supporter

Languages: English (English )

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

Hi David,

I will need to look at an example on your site to see if everything was setup correctly.
Would you mind allowing me to have admin access to the website so that I can have a more detailed look at this for you ?

Please where applicable please provide me with a link to an example page where I can see the issue.

I've enabled the private fields for your next response.

Thanks,
Shane

#2313349

Shane
Supporter

Languages: English (English )

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

Hi David,

The reason why your view is returning no results is because you're filtering for a custom field that is not on your Training Actions CPT.

Given that your view is displaying this post type you can only filter your view by the custom fields that are attached in the field group below.
hidden link

What Post Type is the Course Topic custom field on ?

Thanks,
Shane

#2314207

Hi Shane,
yes, this is the issue because I opened this ticket.

I want to filter post types "Training Actions CPT" with the value of the field "Temàtica del curs" from the Course CPT , wich is referenced from "Training Actions CPT".

thanks

#2314271

Shane
Supporter

Languages: English (English )

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

Hi David,

As mentioned previously this actually won't be possible to do.

You can only filter your posts by Attributes of that post. You won't be able to filter your posts from custom fields on a different post type. This will result in no items being displayed because that data is not present on the CPT being filtered.

Essentially what you're trying to do won't be possible if that custom field remains on another post type.

Thanks,
Shane