Skip to content

Instantly share code, notes, and snippets.

@stephanieleary
Last active June 5, 2018 20:39
Show Gist options
  • Save stephanieleary/b5894768608d4afa3636f64ba73b6e6f to your computer and use it in GitHub Desktop.
Save stephanieleary/b5894768608d4afa3636f64ba73b6e6f to your computer and use it in GitHub Desktop.
Filter Genesis "no posts found" message
<?php
add_filter( 'genesis_noposts_text', 'my_custom_404_message', 10, 2 );
function my_custom_404_message( $text ) {
$queried_object = get_queried_object();
if ( isset( $queried_object->post_status ) && 'private' == $queried_object->post_status && !is_user_logged_in() )
$text = sprintf( __( 'This page is restricted. Please <a href="%s">log in or register</a>.' ), wp_login_url( $_SERVER['REQUEST_URI'] ) );
elseif ( is_search() )
$text = __( 'I could not find any entries that matched your search. Would you like to try again?' ) . get_search_form( false );
else
$text = __( 'There are no entries in this section. Would you like to search the site?' ) . get_search_form( false );
return $text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment