Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › How to weight post parents over children
This topic contains 2 replies, has 2 voices, and was last updated by joelwarren 6 years, 4 months ago.
- AuthorPosts
- April 26, 2018 at 4:09 am #17645
What we are after, when searching “Hakea” results returning:
· 102: Report of an announced inspection of Hakea prison
· 81: Report of an announced inspection of Hakea prison
· 63: Report of an announced inspection of Hakea prison
· 45: Report of an announced inspection of Hakea prison
· Then in date order any other publication where Hakea is mentioned
Because these reports cpt have children under them, it would be ok to exclude the children of reports cpt.
cheers,
JoelApril 26, 2018 at 8:50 am #17648Hi,
For exclusions, under the Advanced Options -> Exclude results you have options to exlude by taxonomy terms/users/date or by ID or manually.
However, there is a query argument that can be accessed via code, where you can specify a post parents – so only posts that are children of these parents are displayed.
For example, if you need only the top level items, then setting the post parent to 0 will do the trick. You can also specify more than one post parent ID as well. This knowledge-base article has a sample code: Limiting results to specific posts by parent IDTo include only top level posts, then set the $ids array to:
Best,$ids = array(0);
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
April 26, 2018 at 10:46 am #17654Great thanks Ernest
- AuthorPosts
You must be logged in to reply to this topic.