Modifying the Go Back link to avoid losing search parameters
The Go Back link of the Single Entry page redirects the user to the Multiple Entries page. However, if the user performs a search, the Go Back link will lose the search parameters when returning to the Multiple Entries page.
Using the code snippet below, these search parameters will be kept, and the user will be redirected to the search results.
add_filter( 'gravityview/template/field/entry_link', function ( $output, $href ) {
if ( empty( $_GET ) ) {
return $output;
}
$new_href = add_query_arg( (array) $_GET, $href );
return str_replace( $href, $new_href, $output );
}, 10, 2 );
add_filter( 'gravityview/template/links/back/url', function ( $href ) {
if ( empty( $_GET ) ) {
return $href;
}
return add_query_arg( (array) $_GET, $href );
}, 10, 2 );
See how to add this code snippet to your website: Where to put code samples.