WordPress.org

Ready to get started?Download WordPress

Forums

Custom search query for child pages (2 posts)

  1. drummergirl
    Member
    Posted 4 years ago #

    I am trying to modify my search page so that it pulls in thumbnail images (already listed in a custom field) from the child pages of a specific parent if any content, tile or tag from those child pages matches the query string for the search. I want that at the top of the search results (should only result in 10 images or less) and then the other search results below that in the normal format.

    I have tried several configurations but I can't get it working. Any help would be greatly appreciated.

  2. drummergirl
    Member
    Posted 3 years ago #

    I'm still trying to get this to work... the closest I can get is to use this conditional:

    if ( $post->post_parent == '1940' ) but my problem is that there are grandchildren under the parent pages that also need to show up in the search results (not just the immediate children). Since there are literally hundreds of these parents and grandchildren under this main page, listing each one as a separate conditional would be silly.

    How can I create a search query that will locate all of the sub-pages of a specific parent, including all grandchildren and display them only if they match the search string? Any ideas?

    Surely this isn't that complicated?

Topic Closed

This topic has been closed to new replies.

About this Topic