Changing text in content-none breaks search results

We are trying to customize the text displayed from _content-none.php when a search produces no results.

We have followed the directions for using a child theme to accomplish this detailed in the following link:

When we go through this process and test with a string that will not return results, we get a blank page with no text whatsoever. The search button functionality is also gone at this point.

I have also tried adding a function to the child theme’s functions.php as detailed in this link:

Any help will be much appreciated!

Hi @bjmiller,

Please remove the customization you have added then try adding this code in the functions.php file of the child theme instead:

// Translate Strings
add_filter( 'gettext', 'translate_x_strings', 20, 3 );

function translate_x_strings( $translated_text, $text, $domain ) {

        switch ( $translated_text ) {

            case "Nothing to Show Right Now" :

                $translated_text = __( "Translation here.", '__x__' );
                break;

            case "It appears whatever you were looking for is no longer here or perhaps wasn't here to begin with. You might want to try starting over from the homepage to see if you can find what you're after from there." :

                $translated_text = __( "Translation here.", '__x__' );
                break;
        }

    return $translated_text;
}

Hope this helps.

Added that to child theme’s functions.php after removing the custom _content-none.php from child theme. Site broke and would not load.

Hello @bjmiller,

There is no error in your site:

By the way, we could not insert the code into your child theme’s functions.php file because the file editing in Appearance > Theme Editor is not allowed. All edits must be done manually by downloading/uploading the mentioned file.

Please be very careful in copying and pasting of the code. In most cases, the quotes were no longer correct when pasting the code. This is usually the case for Windows users. Please double check the quotes. It must be 'some text' and "some text".

Hope this helps. Please let us know how it goes.

Hi, RueNel.

Yes. I removed the suggested addition to the child theme’s functions.php to get the site to load correctly again.

I will double check the quotes and try again. Will update with results.

No problem.
Please let us know how it goes.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.