WordPress.org

Support

Support » Plugins and Hacks » Custom search query for child pages

Custom search query for child pages

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

Viewing 1 replies (of 1 total)
  • 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?

Viewing 1 replies (of 1 total)
  • The topic ‘Custom search query for child pages’ is closed to new replies.
Skip to toolbar