Last active
September 11, 2018 22:18
-
-
Save zackkatz/edbd4713afa49e550a9b to your computer and use it in GitHub Desktop.
GravityView - Modify the text displayed when there are no results
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 | |
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 Having the exact same problem issue.
@mammothreach @m-e-h Please see this patch that fixes the search state: GravityKit/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
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.