Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save propertyhive/6e49985115513f8fec8f2635d2a330ea to your computer and use it in GitHub Desktop.
Save propertyhive/6e49985115513f8fec8f2635d2a330ea to your computer and use it in GitHub Desktop.
add_action( "propertyhive_property_imported_kyero_xml", 'set_kyero_statuses', 10, 3 );
function set_kyero_statuses( $post_id, $property, $import_id )
{
wp_suspend_cache_invalidation( true );
wp_defer_term_counting( true );
wp_defer_comment_counting( true );
$department = 'residential-sales';
if ( isset($property->price_freq) && ( (string)$property->price_freq == 'week' || (string)$property->price_freq == 'month' ) )
{
$department = 'residential-lettings';
}
if ( $department == 'residential-sales' )
{
wp_set_post_terms( $post_id, 123, 'availability' ); // Change '123' for 'For Sale' availability ID
}
elseif ( $department == 'residential-lettings' )
{
wp_set_post_terms( $post_id, 321, 'availability' ); // Change '321' for 'To Let' availability ID
}
wp_suspend_cache_invalidation( false );
wp_defer_term_counting( false );
wp_defer_comment_counting( false );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment