- This topic has 9 replies, 4 voices, and was last updated 1 year, 6 months ago by
Tom.
-
AuthorPosts
-
December 4, 2020 at 5:31 am #1567095
Liana Ghazarian
Hi,
How can I change the text for search result pages, both positive and negative? My site is in armenian, but even if i change the wordpress language to armenian, the search results page are in english. I still have
Search results for ‘fqsdqfsq’
Nothing Found
Sorry, but nothing matched your search terms. Please try again with some different keywordsAnother option, maybe easier is how to remove any text from these pages?
I found this code in discussions and placed in in styles.css of the child theme, but no results. add_filter( ‘gettext’, function( $text ) {
if ( ‘Search Results for: %s’ === $text ) {
$text = ‘%s’;
}return $text;
} );Thank you
December 4, 2020 at 5:31 am #1567096Liana Ghazarian
add_filter( ‘gettext’, function( $text ) {
if ( ‘Search Results for: %s’ === $text ) {
$text = ‘%s’;
}return $text;
} );December 4, 2020 at 6:20 am #1567165Elvin
StaffCustomer SupportHi,
Can you try this instead?
add_filter( 'gettext', function( $text ) { if ( 'Search Results for: %s' === $text ) { $text = '%s'; } return $text; } );
It’s basically the same except I’ve replaced all the curly quotation marks
‘
and’
with straight quotation marks'
. It works on my end as shown here: https://share.getcloudapp.com/BluQZWk5A wise man once said:
"Have you cleared your cache?"December 4, 2020 at 8:17 am #1567465Liana Ghazarian
I think my You searched for text was comming from Breadcrumbs, not GP.
But I do still have this text in english
Nothing Found
Sorry, but nothing matched your search terms. Please try again with some different keywords.Is there any way for me to have it in a different language
December 4, 2020 at 12:15 pm #1567784Tom
Lead DeveloperLead DeveloperHi there,
You can overwrite the no results template completely:
add_filter( 'generate_do_template_part', function( $do, $template ) { if ( 'none' === $template ) { $do = false; } return $do; }, 10, 2 ); add_action( 'generate_before_do_template_part', function( $template ) { if ( 'none' !== $template ) { return; } ?> <div class="no-results not-found"> <div class="inside-article"> <h1>Nothing found.</h1> <p>Your custom text here.</p> </div> </div> <?php } );
That way you can change the text or add it to it as much as you want 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 4, 2020 at 12:48 pm #1567825Baz
Hi Tom and Liana, apologies for hijacking this thread.
I just tried that code and it works great. However, the search form disappears, so is there any code I could add to make it reappear?
Thanks.
December 5, 2020 at 12:01 am #1568140Liana Ghazarian
This worked perfect for me especially since I didn’t want the search form that Baz mentioned.
I hava d related question though. Only the search page in my breadcrumbs is in english. How do I change the name of this generated page?
December 5, 2020 at 11:47 am #1568721Tom
Lead DeveloperLead DeveloperTo add the search form, you can use this function:
<?php get_search_form(); ?>
As for breadcrumbs, it’s likely that the plugin generating the breadcrumbs is automatically naming it – you may need to check with them.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 6, 2020 at 1:58 am #1569049Liana Ghazarian
Thanks a lot
December 6, 2020 at 11:59 am #1569587Tom
Lead DeveloperLead DeveloperNo problem!
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.