Hi @redcrew, great question!
There is in fact, an ongoing conversation on how to add this exact feature to the next bundled theme, Twenty Twenty-Three here.
For Twenty Twenty-Two, we could add a block with you “Nothing found” message to the Search template and leverage the search-no-results
CSS class that is added automatically to the <body>
tag to hide said message when results ARE found.
1. Head to your “Search” template, via the Site Editor or by adding this URL to your site:
wp-admin/site-editor.php?postType=wp_template&postId=twentytwentytwo%2F%2Fsearch
2. Insert a block to include your message. Give this block a class name such as search-no-results-message
, as seen below:
3. Add the following CSS to your site:
/* Hide Custom "Nothing Found" message if we have results*/
.search-no-results-message {
display:none;
}
/* Show Custom message if nothing is found */
.search-no-results .search-no-results-message {
display:block;
}
(To access the CSS editor in the Customizer in Twenty Twenty-Two you’d need to add this after your site’s URL: /wp-admin/customize.php
)
The CSS code above will hide the block you just added and only show it when there are no results.
Please let me know if you have any questions or if you encounter any difficulties in doing this.
-
This reply was modified 2 years, 2 months ago by Alvaro Gómez.
-
This reply was modified 2 years, 2 months ago by Alvaro Gómez.
-
This reply was modified 2 years, 2 months ago by Alvaro Gómez.
-
This reply was modified 2 years, 2 months ago by Alvaro Gómez.
-
This reply was modified 2 years, 2 months ago by Alvaro Gómez.
-
This reply was modified 2 years, 2 months ago by Alvaro Gómez.
-
This reply was modified 2 years, 2 months ago by Alvaro Gómez.