Skip Navigation

[Closed] CPT with 2 ancestors: filter by shortcode with only one of the two

This support ticket is created 3 years, 9 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 3 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1721915

I have a cpt which has 2 ancestors. I need to list items in a view filtered by one of the two ancestors. How can I specify which of the two ancestors is indicated in the filter shortcode parameter?

This is the situation: CPT < Parent 1 || Parent 2

I want to add a view shorcode like this : [view name wpvchildof="11508" ancestor="parent 2"]

Is it possible?

#1722041

Hi, there's nothing exactly like this because it is not possible to add more than one post relationship search filter to any View, and each post relationship must be filtered using a separate Query Filter. Instead, you could create two separate but similar Views - one View with filters for post relationship A and another View with filters for post relationship B. Then use a conditional or a custom shortcode to determine which View should be displayed.

Is this approach possible for your site, or can you explain why it is not possible? I might be able to think of another alternative if you tell me more about what you want to accomplish, and why two separate Views would not be feasible.

#1722049

It is okay. I do not need to add more than one post relationship filter. I just want to specify what is the relationship that I am filtering. Is it possible to choose what ancestor is used in the filter?

#1722183
Screen Shot 2020-07-29 at 4.40.59 PM.png

Okay I misunderstood, sorry. It sounds like you want to be able to set one of the front-end filter options to be automatically selected when the page loads. Is this correct? The only way to set a front-end filter automatically when the page loads is to place the selected value in a URL parameter. Unfortunately you cannot use shortcode attributes to accomplish the same thing. This is true for any other custom search filter, like a custom field filter. You must create links to this page with the correct URL parameter already added, like https://yoursite.com/some-page-with-filters/?wpv-relationship-filter=12345, where the ID of the related post you want selected is 12345. That will send the User to the page with the correct related post selected automatically. The URL parameter may not be wpv-relationship-filter on your site, it depends on the settings in your Query Filter. See the screenshot here for an example - your parameter may be different.

I can help you create links in this format if you need assistance, just let me know. I will need to see the View on the front-end of your site to provide the correct markup.

The topic ‘[Closed] CPT with 2 ancestors: filter by shortcode with only one of the two’ is closed to new replies.