Support » Plugins » Hacks » Need to Search Page Content

  • I need to be able to search page content, and was trying to modify functions.php to allow me to search pages with search.php and searchform.php with this code I found in the forums:

    function SearchFilter($query) {
         if ($query->is_search) {
        // Insert the specific post type you want to search
         $query->set('post_type', array('post', 'page'));
       return $query;
    // This filter will jump into the loop and arrange our results before they're returned

    But this doesn’t search my page content either. Can anyone tell me what I need to do so that WordPress will search page content?

    I tried the Search Everything plugin, which is supposed to give an option to allow the searching of page content, but the option for page content isn’t there. I saw it on the install screen shot, so know it is supposed to exist.

    No reply on forum for Search Everything, nor from author.

    Can I make this work with functions.php? Is there a better way?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    The snippet you provided should return all posts and pages (instead of the usual posts only) that match the search terms in either title or content, using the default search box. I couldn’t say why it’s not working for you.

Viewing 1 replies (of 1 total)
  • The topic ‘Need to Search Page Content’ is closed to new replies.