Genesis – How to Change Text Shown When No Posts Are Found

WordPress uses the WP_Query class to handle requests for pages/posts to a WordPress blog.?By default, Genesis displays the following text when no posts are found during such a request:

Sorry, no posts matched your criteria.

This might happen for example when displaying a category archive page and there are currently no posts in that category or when a search returns no results.

However, you can change this text by using the following code:

/** Change Text Shown When No Posts Are Found */
add_filter('genesis_noposts_text', 'wpb_noposts_text');
function wpb_noposts_text($text)
{
  $text = '<span class="noposts-text">' . __('Your request did not return any results, please check back later.', 'wpb') . '</span>';

  return $text;
}

If you want to style the text that is displayed just add some styles in the style-sheet for .noposts-text.

  • Category:

Posted by Eugen Oprea

I am passionate about technology and I love to help people confused by technology build a remarkable presence online. You can also find me on Twitter, Google+, Facebook, or LinkedIn.