Skip Navigation

[Résolu] Filter by parent Posts

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
How can I add a Custom Filter for many parent posts?

Solution:
From the Custom Filter section, select "new filter" and then "post relationship".

Then, select a multiple Choice like in the screenshot:
https://toolset.com/wp-content/uploads/2017/08/558552-Parent_Post_Filter.png?x28882

This will generate a Front End Custom Filter where you can filter by several parent posts.

This support ticket is created Il y a 6 années et 9 mois. 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Marqué : 

This topic contains 9 réponses, has 2 voix.

Last updated by alexV-8 Il y a 6 années et 9 mois.

Assisted by: Beda.

Auteur
Publications
#558208

So I know with ids you can pass in multiple values but it would be great to do the same with ?wpv-pr-child-of=XXX filters on a view.
I have a test page here and the first one shows the child of 1803 but the second link does not because it only supports passing in a single parent.
hidden link
hidden link

#558466

If we talk about a Custom Filter in the View, you can do that.

When you insert a Custom Filter for a Post Relationship, you can actually choose how the Filter Should look alike, right?

Well, there is alos a "multiselect" option.

This allows you exactly that:
- Filter by several parents.

The URL parameter then just gets added twice to the URL.

#558548

Hello Beda, as soon as I select the Post relationship filter, I don't get the same options as you do when you select a custom field. I don't see any way in custom fields to select the parent by id for example. I see I could select a non-ID field from the parent as long as it is a types custom field I add. I would assume even selecting that parent custom field would not help since you are not telling the view this is a parent relationship. But yes if could do a custom query using a post relationship filter that would work for my needs. Am I missing something? I could create screenshots if it would help.

Alex ~hidden link

#558552
Parent Post Filter.png

Yes, you are missing that you can already search by multiple Parent Posts.

I added a screenshot.

I seem to miss what you mean, or I misexplained myself and could not pass you the information accurately.

Please let me know, if needed with visual explanations, sometimes I seem to be a bit "slow" 🙁

#558562
1.png

Oh, that looks like what I need, but I don't know how to get to that screenshot. I don't see how to get there on the views page and I am not using layouts. See my screenshot of what I was referring to.

#558567

Ah, no.
My screenshot is from the Custom Filter section, a little more down.

There, select "new filter" and then "post relationship".

The problem is, you cannot pass more than one Post to the Query argument, instead, the Query argument gets added for each Post Queried in a multiple select field.

So the URL looks like this for one post only:
?wpv-url-parameter=your_post

And like this for more than one post:
?wpv-url-parameter=your_post&?wpv-url-parameter=your_post

That is the only way you could "hardcode" this in the Query Filter (you need to call the specific URL with arguments manually in the front end in this case)

#558569

I figured it out. I can do it when creating a view and adding custom search. Is there a way to edit an existing view to add this? Not a big deal and you don't need to respond if you don't want to. 🙂

#558570

Yeah, of course.

Make sure the Custom Filter section is displayed when you edit the View (otherwise activate it in the Screen Options on top) and then insert it.

If you already inserted a Query Filter for this, delete it before you proceed with adding a Custom Filter.

#558573

I had to re-open this ticket, to say this

You are the king!!! Works perfectly. Thanks

#558574

Solved

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.