Better Search Results

Code for my YouTube video on improve the WordPress search functionality and user experience.

This post is just a holding zone for code snippets from this video:

Search Title Code:

add_shortcode('search_title', 'get_search_title');
function get_search_title() {
    if (is_search()) {
        return '<p class="search-for">Search results for:</p><h1 class="search-title">' . get_search_query() . '</h1>';
    } elseif (is_archive()) {
        return '<h1 class="search-title">' . get_the_archive_title() . '</h1>';
    } 
}

SEOPress Meta Title and Meta Description Meta Key:

_seopress_titles_desc
_seopress_titles_title

Data Attribute for Search Modal:

data-gpmodal-trigger="gp-search"

Kyle Van Deusen

Co-founder of The Admin Bar Community, owner of OGAL Web Design, and a GeneratePress & GenerateBlocks enthusiast.

For official support, please visit the forums for GeneratePress or GenerateBlocks

If you're looking to have a website built with GeneratePress & GenerateBlocks, then visit my agency website.

1 thought on “Better Search Results”

  1. This is great Kyle. I’ve been looking for videos on this and yours was the only one that I found. It was easy to implement and now that I’ve got the templates ready to go I can add more info to the search results that may otherwise be missed. Like a lead magnet for example 🙂

    Reply

Leave a Comment