|
/ Documentation /Custom Code Snippets/Astra Header & Footer Filters/ How to Change the “Search Results For” String

How to Change the “Search Results For” String

If you’re using Astra’s search option on a website and want to change the default string “Search Results For,” you’re in luck! This article will guide you through the process.

To modify the above string, add the following code to your child theme’s functions.php file.

add_filter( 'astra_the_search_page_title', 'my_function', 10 ); 

function my_function() {
    return sprintf( __( 'Add Custom Text Here: %s', 'astra' ), '<span>' . get_search_query() . '</span>' );
}

Here’s how you can do it:

Navigate to Appearance > Theme File Editor, and access the functions.php file.

Paste the above code here and click on the Update File button.

Verify these changes on your website.

That’s it! The text inside “return sprintf( __( ‘Add Custom Text Here: %s’, ‘astra’ )” in the code can be replaced according to your preferred text.

If you face any issues with the above, please reach out to our support team.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page
Scroll to Top