If you’re using a WordPress site with a default theme such as TwentyTwenty, you might want to learn how to change the default WordPress ‘could not find any results’ text that appears if a user uses the search form on your page but there is no matching content:
Looking to get a head start on your next software interview? Pickup a copy of the best book to prepare: Cracking The Coding Interview!
Creating a custom no results prompt for your search is useful to improve the theme of your site. For instance, if a user cannot find content, you can update the prompt message to include your contact info and they can send you what they were looking for, allowing you to generate useful content for your site with guaranteed user interest. To customize the ‘could not find any results’ no result text you will need to modify the theme php:
- Open from your wordpress dashboard side bar the Appearance->Editor menu.
- Find your theme’s index.php file
- Find the section of code containing your default text, i.e:
$archive_subtitle = __( 'We could not find any results for your search. You can give it another try through the search form below.', 'twentytwenty' );
- Update the text to your desired custom message (note if your new text includes a ‘ character you you will need to escape it with \’) , and then update the file. Adding HTML into your default message no result message is supported, for example:
$archive_subtitle = __( 'We could not find any results for your search. You can give it another try through the search form below.<br><br>Can\'t find your dorm? Email us your university and dorm at <a href = "mailto:firstname.lastname@example.org">email@example.com</a> and we\'ll create the missing page!', 'twentytwenty' );
Following these simple instructions, the default no result search text will now be updated:
Check out these updates live at collegedormreviews.com