In this tutorial, we’ll look at different ways to modify the ‘Sorry, no posts matched your criteria’ text.
This text is displayed when using the search built into WordPress or when no posts are assigned to categories or tags.
We’ll need to use a filter hook to change this text as its already built into the core Genesis files.
Here’s the filter for changing the no post text:
Default value: __(‘Sorry, no posts matched your criteria.’, ‘genesis’)
Applied to the no post text which is returned when a query is made with no results in the genesis_do_noposts function.
Like the Genesis action hooks, you’ll also find a list of all filter hooks for Genesis which you can use to modify existing add_action functions using Genesis action hooks.
Here’s the hook which is used to generate the default no posts text.
Filter Hook Code
There’s different ways to change the no post text.
This code will enable you to add style to both the title and text. You could even change the code if you want to add even more styling.
This code is pretty basic and also enables you to style the text.
Here’s some sample CSS code you can use to style your no post text and even hide it altogether.
You’ll find the code in the genesis > lib > structure > post.php file starting on line 223.
Click To Enlarge Image
hi there- i’m a total beginner. I know nothing about code but would like to learn some copy and paste basics for specific things like this. Can you recommend a beginner’s resource for modifying code in a genesis child theme? I’m not even sure how to go into the style sheet.
thanks!
Hello Kris.
Can you be more specific?
It depends on your theme and what you want to modify.
If you’re using a child theme by StudioPress, they offer a large range of code snippets based on what the most popular questions are for modifying different default functionality.
hi thanks for your response
i’m using the lifestyle theme. I want to modify the size of the header and i’m not sure how.
I also want to add a dedicated menu (for blog categories ) ONLY on my blog page.
I know there are code snippets but i’m not even sure where / how to add them i the editor.
thanks
I might hide the “sorry no posts” message with CSS, but that is not what I want; I would like to replace it with a different text. Maybe through the theme’s functions.php?
NO problem. Use the code in the post.
Thanks for this tip.
But I would like to do this only in a specific child theme. Is that possible?
Hi Hugo
Which child theme are you using?
The Minimum theme.
Did you try the CSS code?
Great little filter I’d never thought about before. Thanks for sharing!
No worries Carrie. I didn’t know about this one and was using CSS to hide the text which probably isn’t the best.