Search Page

I have several questions regarding the search page.

1st question is how do I make it work? When I search for something on my website like a word that I know its present more than once on the site it does not appear in search results.

2nd question is how do I change the header and footer of the page in the image that I uploaded. Must I create another page and assign it instead of that one?

Thank you for your time!

Hi Carp,

Thanks for writing in! I have re-generated your permalink settings (Settings -> Permalinks) and then your search results seems to be working now.

To change header or footer for a particular page, first load your header or footer content builders in Pro and then click on a desired header that you like.

Then from the right hand side, you can click on a page which you want to appear that header/footer.

You can also check our tutorial with regard to header and footer builders from here (https://theme.co/apex/forum/t/pro-header-and-footer-builder-introduction/103).

Hope that helps.

Thank you, Sir. The thing is if I search for something and it is not found on the website I get to the page in the image above and on that page I cannot change the header and the footer. My header and footer are checked for showing on all pages but it does not show on the page where I get no results from the search function. Just write something in the search window and you will see.

Hi,

To fix it, you can add the code below in your child theme’s functions.php file

add_filter('cs_match_header_assignment', 'custom_search_header');
function custom_search_header($match) {
    if ( $GLOBALS['wp_query']->found_posts == 0 ) {
        $match = 40; // the post ID for your header
    }
    return $match;
}

Please add it after this line


// Additional Functions
// =============================================================================

Hope this helps

Thank you, Sir! That fixed the header, and can you please give me something for the footer? Now it looks like this.

Thank you for your time and support!

Hi Carp,

Please try updating the previous code to this:

add_filter('cs_match_header_assignment', 'custom_search_header');
function custom_search_header($match) {
    if ( $GLOBALS['wp_query']->found_posts == 0 ) {
        $match = 40; // the post ID for your header
    }
    return $match;
}

add_filter('cs_match_footer_assignment', 'custom_search_footer');
function custom_search_footer($match) {
    if ( $GLOBALS['wp_query']->found_posts == 0 ) {
        $match = 40; // the post ID for your header
    }
    return $match;
}

Hope it helps :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.