[Support request] Customize Search Results Title

Home Forums Support [Support request] Customize Search Results Title

Home Forums Support Customize Search Results Title

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2337957
    John

    Hi, Please, How I can change Search Results Title background from white to this color: #F5F4EE, text alignment: Center, Text Color: #F46100 and Text: Results for “search query” e.g. Results for “cars”

    #2338270
    David
    Staff
    Customer Support

    Hi there,

    try adding this CSS:

    .search.separate-containers .page-header {
        background-color: #F5F4EE;
        color: #F46100;
        text-align: center;
    }
    #2338725
    John

    Worked! Thanks David, But how I can change the Text to: Results for “search query” e.g. Results for “cars”

    #2338861
    David
    Staff
    Customer Support

    You can change the prefix text using the snippet provided here:

    https://generatepress.com/forums/topic/modify-search-title/#post-2077758

    Do you want the search query wrapped in "" quotes too ?

    #2339493
    John

    Yes, Like Results for “cars”

    #2339865
    David
    Staff
    Customer Support

    Try this snippet instead:

    add_filter('generate_search_title_output',function($title) {
        $title = sprintf(
            '<header %s><h1 class="page-title">%s</h1></header>',
            generate_get_attr( 'page-header' ),
            sprintf(
                /* translators: 1: Search query name */
                __( 'Results for: "%s"', 'generatepress' ),
                '<span>' . get_search_query() . '</span>'
            )
        )
        return $title;
    });
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.