• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

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

Reader Interactions

Comments

  1. kris says

    May 22, 2014 at 6:24 pm

    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!

    Log in to Reply
    • Brad Dalton says

      May 23, 2014 at 5:05 am

      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.

      Log in to Reply
      • kristen says

        June 5, 2014 at 7:19 pm

        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

        Log in to Reply
  2. Hugo Callens says

    September 28, 2013 at 6:10 am

    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?

    Log in to Reply
    • Brad Dalton says

      September 28, 2013 at 7:03 pm

      NO problem. Use the code in the post.

      Log in to Reply
  3. Hugo Callens says

    September 27, 2013 at 3:27 pm

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

    Log in to Reply
    • Brad Dalton says

      September 27, 2013 at 5:49 pm

      Hi Hugo

      Which child theme are you using?

      Log in to Reply
      • Hugo Callens says

        September 27, 2013 at 8:57 pm

        The Minimum theme.

        Log in to Reply
        • Brad Dalton says

          September 27, 2013 at 9:15 pm

          Did you try the CSS code?

          Log in to Reply
  4. Carrie Dils says

    May 6, 2013 at 5:57 pm

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

    Log in to Reply
    • Brad Dalton says

      May 6, 2013 at 6:00 pm

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

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.