Search Box that searches through pages (4 posts)

  1. Kieran Hunter
    Posted 3 years ago #


    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


  2. Andrew
    Forum moderator
    Posted 3 years ago #

    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.

  3. curtismchale
    Posted 3 years ago #

    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.

  4. Kieran Hunter
    Posted 3 years ago #


    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

Topic Closed

This topic has been closed to new replies.

About this Topic