Customize The Sorry No Posts Matched Your Criteria Text In Genesis

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:

genesis_noposts_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.

genesis_loop_else This hook executes after the else : statement in all loop blocks. The content attached to this hook will only display if there are no posts available when a loop is executed.

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

genesis do no posts


Comments

11 responses to “Customize The Sorry No Posts Matched Your Criteria Text In Genesis”

  1. 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!

    1. Brad Dalton Avatar
      Brad Dalton

      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.

      1. kristen Avatar
        kristen

        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

  2. Hugo Callens Avatar
    Hugo Callens

    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?

    1. Brad Dalton Avatar
      Brad Dalton

      NO problem. Use the code in the post.

  3. Hugo Callens Avatar
    Hugo Callens

    Thanks for this tip.
    But I would like to do this only in a specific child theme. Is that possible?

    1. Brad Dalton Avatar
      Brad Dalton

      Hi Hugo

      Which child theme are you using?

      1. Hugo Callens Avatar
        Hugo Callens

        The Minimum theme.

        1. Brad Dalton Avatar
          Brad Dalton

          Did you try the CSS code?

  4. Carrie Dils Avatar
    Carrie Dils

    Great little filter I’d never thought about before. Thanks for sharing!

    1. Brad Dalton Avatar
      Brad Dalton

      No worries Carrie. I didn’t know about this one and was using CSS to hide the text which probably isn’t the best.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.