[Resolved] Change language search

Home Forums Support [Resolved] Change language search

Home Forums Support Change language search

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #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 keywords

    Another 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

    #1567096
    Liana Ghazarian

    add_filter( ‘gettext’, function( $text ) {
    if ( ‘Search Results for: %s’ === $text ) {
    $text = ‘%s’;
    }

    return $text;
    } );

    #1567165
    Elvin
    Staff
    Customer Support

    Hi,

    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/BluQZWk5

    A wise man once said:
    "Have you cleared your cache?"

    #1567465
    Liana 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

    #1567784
    Tom
    Lead Developer
    Lead Developer

    Hi 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 🙂

    #1567825
    Baz

    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.

    #1568140
    Liana 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?

    #1568721
    Tom
    Lead Developer
    Lead Developer

    To 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.

    #1569049
    Liana Ghazarian

    Thanks a lot

    #1569587
    Tom
    Lead Developer
    Lead Developer
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.