Support » Plugins » Hacks » Make search only search children of a specific page

  • russtuck91


    I have a Wiki section on my site, and I want to modify WordPress’s native search to only search pages in this Wiki, or in other words, only children of page #278.
    I’ve succeeded in listing children pages of a given page with wp_list_pages and the parameter ‘child_of’, so I’ve been trying for something like that. Two attempts so far:
    In the search page…

    <?php if ( have_posts(array('child_of'=>278)) ) : ?>
    <?php while ( have_posts(array('child_of'=>278)) ) : the_post(array('child_of'=>278)) ?>

    And alternatively in my functions file…

    function SearchWikiPages($query) {
    	if ($query->is_search) {
    	return $query;

    So far with no luck. If anyone knows how I can do this please help. I would not be opposed to using a plugin, or any other creative solution if it gets what I need.

  • The topic ‘Make search only search children of a specific page’ is closed to new replies.