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:


Data Attribute for Search Modal:


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.

Leave a Comment