Created
February 15, 2019 18:53
-
-
Save altoin/12b7dd5966e3055d46aabe7f1fe28fb9 to your computer and use it in GitHub Desktop.
Display a custom message when no entries are returned, for a specific View ID
This file contains 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 //MAKE SURE TO REMOVE THIS WHOLE LINE FIRST | |
add_filter( 'gravityview/template/text/no_entries', 'modify_gravityview_no_entries_text', 10, 3 ); | |
function modify_gravityview_no_entries_text( $existing_text, $is_search = false, $context = null ) { | |
$view_id = $context->view->ID; | |
if($view_id == 8) //Change this number to your View ID | |
{ | |
if( $is_search ) { | |
$return = 'Your search came up empty! [Use your own new search text]'; | |
} else { | |
$return = "There just aren't any results! [Use your own text]"; | |
} | |
} | |
//You can repeat this section for another View | |
elseif($view_id == 9) //Change this number to your View ID | |
{ | |
if( $is_search ) { | |
$return = 'Your search came up empty! [Use your own new search text]'; | |
} else { | |
$return = "There just aren't any results! [Use your own text]"; | |
} | |
} | |
// End of repeatable block | |
//If you have more than 2 View where you want to use the code, Please copy and paste the repeatable block before this comment, and remember to update the View ID | |
else{ | |
return; | |
} | |
return $return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment