Customize the "Nothing Found" Text on Search Results

How to Customize the “Nothing Found” Text on Search Results Without Plugins? :thinking:

Here’s how you can transform:

From this:

To This


Step 1: Add This Code to Your Child Theme’s functions.php File


add_action( 'template_redirect', 'replace_nothing_found_text' );

function replace_nothing_found_text() {
    // Start output buffering for specific templates
    if ( is_search() || is_archive() || is_home() ) {
        ob_start( 'custom_nothing_found_text_callback' );
    }
}

function custom_nothing_found_text_callback( $buffer ) {
    // Replace "Nothing found" and other texts in the output buffer
    $buffer = str_replace( 'Nothing found', 'Oops! Nothing here yet.', $buffer );
    $buffer = str_replace(
        'Sorry, but nothing matched your search terms. Please try again with some different keywords.',
        'Looks like we couldn’t find a match for your search. Try exploring with different keywords, locations, or categories! 🌟',
        $buffer
    );

    return $buffer;
}

Step 2: Modify the Text as Needed

You can change the Oops! Nothing here yet... and Looks like we couldn’t find ... part to any text you like.

Note: First, create a child theme for ListingHive. This is important because all your customizations will remain safe even after you update HivePress in the future. So, any codes or tweaks you find on forums or guides can safely be added to your child theme’s functions.php. (Check out - How to create child theme in hivepress)

Enjoy customizing your HivePress site! :rocket:

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