Last active
June 5, 2018 20:39
-
-
Save stephanieleary/b5894768608d4afa3636f64ba73b6e6f to your computer and use it in GitHub Desktop.
Filter Genesis "no posts found" message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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