Support » How-To and Troubleshooting » Search Box that searches through pages

Search Box that searches through pages

  • Hello

    I have the wordpress search box on my thesis_185 theme, but as i discoverd a wordpress search box only searches for posts, is there anyway I can get the search box to search for pages?


    Thank you


Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Andrew Nevins


    Forum moderator

    You can contact your theme’s vendors regarding this query/issue. WordPress.org forums are for the core application, themes and plugins distributed on WordPress.org.

    While he is using Thesis, this is not just a Thesis question. Core WordPress functions this way.

    To enable searching of pages you’re going to have a add a bit of code.

    function wptt_add_pages_to_search( $query ){
    if( is_search() ){
    $query->set( 'post_type', array( 'pages', 'posts' ) );
    return $query;
    } // wptt_add_pages_to_search
    add_action( 'pre_get_posts', 'wptt_add_pages_to_search' );

    This will work in your theme functions.php file (of course you need to look at Thesis docs to learn exactly how to do that for Thesis). You will need to remeber to move this when you change themes to maintain the same function in the next theme.


    I have done this but when I search for something it says ‘Sorry, but no results were found’.

    I’m not sure what the problem is

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Search Box that searches through pages’ is closed to new replies.