Skip to content

Instantly share code, notes, and snippets.

@norcross
Created April 18, 2014 01:01
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 norcross/11019640 to your computer and use it in GitHub Desktop.
Save norcross/11019640 to your computer and use it in GitHub Desktop.
add a secondary meta key for sorting
<?php
// extra check for price that can create a sortable value
if ( isset( $property_details['_listing_price'] ) && ! empty( $property_details['_listing_price'] ) ) {
// strip anything other than a decimal
$price_sortable = preg_replace( '/[^0-9\.]/', '', $property_details['_listing_price'] );
// update the value with a floatval check
update_post_meta( $post_id, '_listing_price_sortable', floatval( $price_sortable ) );
} else {
delete_post_meta( $post_id, '_listing_price_sortable' );
}
@toddejones
Copy link

I'm kind of new with this stuff, so bear with me. Is this to be uploaded as a new single file? Main Directory? Includes directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment