Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save propertyhive/fd5ee85b08d9e5f50aaed2b288e8f5d8 to your computer and use it in GitHub Desktop.
Save propertyhive/fd5ee85b08d9e5f50aaed2b288e8f5d8 to your computer and use it in GitHub Desktop.
add_action( "propertyhive_property_imported_reapit_foundations_json", 'situation_as_features', 10, 2 );
function situation_as_features($post_id, $property)
{
if ( isset($property['situation']) && !empty($property['situation']) )
{
// Do existing feature functionality
$features = array();
if ( isset($property['specialFeatures']) && !empty($property['specialFeatures']) )
{
foreach ( $property['specialFeatures'] as $feature )
{
$features[] = trim($feature);
}
}
foreach ( $property['situation'] as $situation )
{
$features[] = trim($situation);
}
update_post_meta( $post_id, '_features', count( $features ) );
$i = 0;
foreach ( $features as $feature )
{
update_post_meta( $post_id, '_feature_' . $i, $feature );
++$i;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment