I've been searching thru all WordPress files for the phrase "search result for", which is displayed on the search result page (search result for (keywords)) but can't find it.
I would like it to be: "You searched for: (keywords)"
Does anybody know where and how to change this?
I've been searching thru all WordPress files for the phrase "search result for", which is displayed on the search result page (search result for (keywords)) but can't find it.
I would like it to be: "You searched for: (keywords)"
Does anybody know where and how to change this?
From your current theme, I recommend creating a child theme using this plugin https://wordpress.org/plugins/child-theme-configurator/. Within the code of the theme, you will find a folder named template-parts which contains some php files, such as search.php. You should now create the same pattern in your child theme, the folder template-parts, and inside it the file search.php with the same content as the original one, and now simply edit the text you mentioned in this newly created file.
I fixed this by adding the following JavaScript in my theme:
addEventListener("DOMContentLoaded", () => {
if (window.location.href.includes("?s=")) {
// You might need to use adjust the archive title selector
// according to the specific class of your header, for example:
// const archiveTitle = document.querySelector(".elementor-heading-title");
// remember, it will get all tags
const archiveTitle = document.getElementsByTagName('H1')[0];
if (!!archiveTitle) {
let text = archiveTitle.innerText;
text = text.replace("Search Results For: ", "Resultados de la búsqueda de: ");
archiveTitle.innerText = text;
}
}
});
This has disadvantage of creating FLUC (flash of un-styled content).
add_filter('document_title_parts', function($parts){
if( is_search() ){
$parts['title'] = sprintf('You searched for: %s',get_search_query());
}
return $parts;
});