Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GravityView - Modify the text displayed when there are no results
<?php
add_filter( 'gravityview/template/text/no_entries', 'modify_gravityview_no_entries_text', 10, 3 );
/**
* Modify the text displayed when there are no entries. (Requires GravityView 2.0 or newer)
*
* Place this code (after <?php) at the bottom of your theme's functions.php file to enable it
*
* @param string $existing_text The existing "No Entries" text
* @param bool $is_search Is the current page a search result, or just a multiple entries screen?
* @param \GV\Template_Context $context The context.
*/
function modify_gravityview_no_entries_text( $existing_text, $is_search = false, $context = null ) {
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]";
}
return $return;
}
@m-e-h

This comment has been minimized.

Copy link

m-e-h commented Apr 1, 2016

Unless I'm mixed up on what the "search results" page is, I can't get this snippet to display anything but the else condition.
I'm searching in the search bar widget on a list view.

@mammothreach

This comment has been minimized.

Copy link

mammothreach commented Sep 8, 2018

@m-e-h Having the exact same problem issue.

@zackkatz

This comment has been minimized.

Copy link
Owner Author

zackkatz commented Sep 11, 2018

@mammothreach @m-e-h Please see this patch that fixes the search state: gravityview/GravityView@a621cf2

Although I doubt this was the issue back in April 2016…hopefully with this latest fix, it will work properly for both of you.

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.