Make search only search children of a specific page (1 post)

  1. russtuck91
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic