Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save propertyhive/3d482ae5c530a0034a4f12e9689d1823 to your computer and use it in GitHub Desktop.
Save propertyhive/3d482ae5c530a0034a4f12e9689d1823 to your computer and use it in GitHub Desktop.
add_action( "propertyhive_property_imported_rex_json", 'rex_import_stuff', 10, 2 );
function rex_import_stuff($post_id, $property)
{
if ( isset($property['listing_agent_1']['name']) && $property['listing_agent_1']['name'] != '' )
{
$args = array(
'post_type' => 'agent',
's' => $property['listing_agent_1']['name'],
'posts_per_page' => 1
);
$neg_query = new WP_Query( $args );
if ( $neg_query->have_posts() )
{
while ( $neg_query->have_posts() )
{
$neg_query->the_post();
update_post_meta($post_id, '_agent_id', get_the_ID());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment