Alter Subheading On Search Results

This is a Developer Level doc.

If you're unfamiliar with PHP and/or editing files, codes and templates, as well as with resolving possible conflict, please seek help from a professional. Under our Support Policy, we don't provide support for modifications and customization.

By default, the subheading on the search results page is "Search results for: ...". If you want to change that subheading, use the following PHP snippet:

function myprefix_custom_search_for_text( $string ) {
	if ( is_search() ) {
		return 'Search results for: '.  esc_html( get_search_query( false ) );
	}
	return $string;
}
add_filter( 'ocean_post_subheading', 'myprefix_custom_search_for_text' );

Adjust Search results for: line per your need.

All PHP snippets should be added via a child theme's functions.php file.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.