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