Skip Navigation

[Resolved] Choosing Parent Posts or Relationship Intermediary to display a View

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

Problem:

Query related posts on many-to-many relationship, and filter by custom fields of intermediate post type.

Solution:

You can setup a view, query the posts of intermediate post type, and filter the result by custom fields of intermediate post type.

Relevant Documentation:

https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items

This support ticket is created 3 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 28 replies, has 3 voices.

Last updated by AlimB3245 3 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1910369
errors.JPG

There are lots of 403 errors in your website, see my screenshot errors.JPG

I don't think we can work on it, if you still need assistance for it, please provide a copy of your website in below private message box.
https://toolset.com/faq/provide-supporters-copy-site/

you can put the package files in your own google drive disk, share the link only, also point out the problem page URL and view URL, I need to test and debug it in my localhost, thanks

#1910505

Hi Luo

The site is around 40GB and it would be quite a task to tranfer all files.. would you be able to SSH it to your localhost?

Anyways I got in touch with the WPMU team where the site is hosted and where most of the plugins are.. so they mentuoned that we have DEFENDER plugin where your IP was blocked and I had whitelisted it.. and there's also another Web Application Firewall where probably your IP was blocked too.. they have added your IP to the whitelist of the WAF too and you should not have the 403 errors according to them..

Could you please check again and let me know if it's all ok?

Regards,
Alim

#1911463

OK, I can login your website, but still see some JS errors in your website.

Please edit the URL you mentioned above:
hidden link
This view block is:
- Query "Opticians" posts
- Filter by custom fields "Participation Category"

How and where do you setup the custom fields "Participation Category"?

I can not find it in field group "Optician Details":
hidden link

If this custom field is in another post type, then it will be a problem, you can only filter the results by post fields of "Opticians", you can not filter the result by other post type's custom fields, it will conducts the problem: no item found.

#1911487

Hi Luo

I get your point.. I assumed that if one custom post (Optician) has a relationship with another custom post (You&Eye Award Events) and that relationship is established in the first query filter then the custom fields of that that relationship could be used.. but I guess I was wrong..

I have OPTICIANS and then YOU&EYE AWARD EVENT.. and then these are in a relationship with the intermediary posts having a custom fields..

Now if I want to display opticians by filtering (query filter and not search filter) for the custom fields in the intermediary posts, what should I be selecting in the VIEW->CONTENT SELECTION and how should I be filtering (query filter) for participation category?

Please do advise.

Regards,
Alim

#1911517

You did not answer my question:

How and where do you setup the custom fields "Participation Category"?

Let me clear the problem again:
If you want to query posts of one post type, and filter the result by custom fields, those custom fields must in in this post type, you can not filter the result by custom fields of other post types.

Hope it is clear.

#1911539

Hi Luo

I do understand your clarification.. and hence the query about what's the right way to view OPTICIANS.. in an earlier message on the same thread Nigel had mentioned I should use OPTICIANS as CONTENT SELECTION ... while I was trying to use the intermediary posts.. so please do advise on how exactly to query for this requirement.

Regarding your question I had provided the links to the custom fields in my PRIVATE MESSAGE as below.. as you can see the PARTICIPATION CATEGORY is in the custom fields of the intermediary post types

This is the Custom Fields EDIT LINK for the Intermediary Post Types
hidden link;

Hope this clarifies your question. Please do let me know if you need any further clarification.

Regards,
Alim

#1911667

Since the custom field "Participation Category" is in intermediate post type, you can try these:
Create a view:
- Query intermediate post type posts
- Filter by "Participation Category" custom fields
- In view's loop, display the related "Opticians" post information

#1912417
Screen Shot 2021-01-20 at 10.30.26 PM.png

Hi Luo

As advised I did the following

Create a view:
- Query intermediate post type posts
- Filter by "Participation Category" custom fields
- In view's loop, display the related "Opticians" post information.. I am currently displaying the logo

(Screenshot attached to display the CONTENT SELECTION and QUERY FILTER)

here's the frontend view... you might have to clear your cache.. it does display the list of opticians

hidden link

Now it's displaying all the opticians.. I need it to display only those opticians that are connected/related to 'You&Eye Award 20-21'..
Here's the list of You&Eye Award Event Posts .. hidden link

and you will see that I have them for 2016,2017 till the current one of 20-21.. I need to display only those opticians that are in the participation category for the '20-21' Award Events.. Please advise.

Also regarding the JS errors I will talk to WPMU to help me with them.. but I found that there were some JS errors that were connected to the Toolset Blocks plugins too.. could you please advise me on how to fix those?

Regards,
Alim

#1912815

How can I login to the website you mentioned above?
hidden link

Can you provide the credentials of this website?

Private message box enabled again

#1913531

Hi Luo

The site is the same

youandeyemag.com is mapped domain to the subsite fourplusmedia.com/youandeyemag/

so the page we were both working on is the same..

there's a plugin wp-ultimo which maps the sub-site fourplusmedia.com/youandeyemag to youandeyemag.com

so
hidden link

is the same as

hidden link

Regards,
Alim

#1914047
relation-filter.JPG

Thanks for the details, I can find and edit the page you mentioned in screenshot:
https://toolset.com/wp-content/uploads/2021/01/1912417-Screen_Shot_2021_01_20_at_10.30.26_PM.png

And I have done below modifications in your website:
1) Dashboard-> Toolset-> Relationships
- find and edit relationship "youandeye-awards-optician":
hidden link
Enable the option "Intermediary Post Type visible in WordPress admin menu", and save

2) Edit the page:
hidden link
Add a relationship filter:
Select posts in a You&Eye Award Events To Opticians relationship that are related to You&Eye Awards 20-21.

See my screenshot:
relationship-filter.JPG

I am not sure how to clear your website cache, you can test it yourself

#1917317

Hi Luo

Thanks for the update..:-)..

On the surface it seems to be working now.. let me test with specific participation categories and confirm..

In the meantime please do advise these 2 queries which are based on what you've done in this ticket.

1) In the CUSTOM FIELD QUERY FILTER, you used in 'IN' for connecting the 'string' and the 'constant' instead of 'equal'.. so does 'in' work as an OR while equal would work as an AND.. is this assumption accurate?

2) You enabled the option "Intermediary Post Type visible in WordPress admin menu" ... how does this work? by enabling this option I assumed it would only display the post types in wp-admin.. I didn't realise it would have an effect on the QUERY FILTER.. what exactly does enabling this option do?

Regards,
Alim

#1918381

Q1) "IN" means: Checks if the custom field value is within the list of compare values
See our document:
https://toolset.com/documentation/user-guides/views/filtering-views-by-custom-fields/#comparison-function
section "Comparison function"

In your case, it works as "OR"

Q2) The intermediate post type is a hidden post type by default, in order to use it in View's query filters, you need to enable that option

#1921461

My issue is resolved now. Thank you!