Skip to content

Instantly share code, notes, and snippets.

@altoin
Created February 15, 2019 18:53
Show Gist options
  • Save altoin/12b7dd5966e3055d46aabe7f1fe28fb9 to your computer and use it in GitHub Desktop.
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
<?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