I'm working on a Genesis child theme with a static front page. This front page contains a search box that just sets the 'search' query var. So it redirects to: http://baseurl/?search=foo

I'm handling the search query var in my page template, because I need to do some custom querying:

    $searchParam = get_query_var('search', null);

    $query_params = [
        'post_type' => 'any',
        'category_name' => 'stories',
        'orderby' => 'date',
        'posts_per_page' => 8,
        'paged' => 1,
        'post_status' => 'publish',
        'post__not_in' => get_option( 'sticky_posts' ),
        'ignore_sticky_posts' => 1,

    if ($searchParam) {
        $query_params['s'] = $searchParam;

    $result = new WP_Query( $query_params );
    ... etc ...

The problem

When this page is set as the front page and I'm doing a search, I'm getting a bare bones search result page and my custom page template isn't being used. When I change the front page to another page it does work as intended. It seems to have something to do with the URL scheme, because if it's the front page the search URL is something like: http://baseurl/?search=foo and when it's not the front page it's something like: http://baseurl/mypage/?search=foo

Any idea how I can set it up so it always uses the regular page template for the current page in case of a search?


I think you can do some changes in the search form so it submits to another page url instead of home. Something like http://baseurl/search-results/?search=foo Where search-results will be the slug of a page with your page template.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.