Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackkatz/8b8f296c6f7dc99d227d to your computer and use it in GitHub Desktop.
Save zackkatz/8b8f296c6f7dc99d227d to your computer and use it in GitHub Desktop.
GravityView - Sort by Address field when sorting by full address
<?php
// Modify sorting when sorting full address
add_filter( 'gravityview/sorting/address', 'modify_gravityview_address_sorting', 10, 3 );
/**
* Override how to sort when sorting address
*
* @since 1.8
*
* @param string $address_part `street`, `street2`, `city`, `state`, `zip`, or `country` (default: `city`)
* @param string $sort_field_id Field used for sorting
* @param int $form_id GF Form ID
*/
function modify_gravityview_address_sorting( 'city', $sort_field_id, $form_id ) {
// Change below to any of the allowed options: street, street2, city, state, zip, country
return 'street';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment