How to weight post parents over children

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 joelwarren 6 years ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #17645
    joelwarren
    joelwarren
    Participant

    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,
    Joel

    #17648
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 ID

    To include only top level posts, then set the $ids array to:

    $ids = array(0);
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #17654
    joelwarren
    joelwarren
    Participant

    Great thanks Ernest

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.