X Theme Search Function Results

Hi X Team,

I’m currently working on this web-site - http://www.mgl.bluetroop.com

When the Search function is used, it simply lists only pages where the search term can be found. Can the Search function be customized to bring up exact text results containing the term AND the page to indicate where it can be found on the site? Also can the results be displayed in blue rather the usual text color? Please advise.

Hello @bluetroop2,

Thanks for writing in! Normally, the search results would display from the posts. If your search is coming from the pages, it will only have the page titles because by default, the page excerpts were disabled by WordPress. You can add the page excerpts manually. To do that, we would highly to suggest that you use a child theme because what you are trying to accomplish requires a template customization. This allows you to make code changes that won’t be overwritten when an X update is released.

After the child theme is set up, please add the following code in your child theme’s functions.php file

// Add manual excerpts to pages
// =============================================================================
add_action( 'init', 'my_add_excerpts_to_pages' );
function my_add_excerpts_to_pages() {
     add_post_type_support( 'page', 'excerpt' );
}
// =============================================================================

After adding this code, you will then need to add manual excerpts to the pages so that it will display on search results. Excerpts are optional hand-crafted summaries of your content that can be used in your theme. Learn more about manual excerpts.

Hope this helps. Please let us know how it goes.

No, not what I want to do with the site. Thank you anyway.

You are most welcome. :slight_smile:

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