Created
April 18, 2014 01:01
-
-
Save norcross/11019640 to your computer and use it in GitHub Desktop.
add a secondary meta key for sorting
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 | |
// 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' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?