Skip to content

Instantly share code, notes, and snippets.

@sillybean sillybean/functions.php
Last active Jun 5, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.