Skip to content

Instantly share code, notes, and snippets.

@g-maclean
Last active October 24, 2024 10:36
Show Gist options
  • Select an option

  • Save g-maclean/4c61cf4950f33a36d4f229515a2be4b2 to your computer and use it in GitHub Desktop.

Select an option

Save g-maclean/4c61cf4950f33a36d4f229515a2be4b2 to your computer and use it in GitHub Desktop.
Use unit ref as title for unit imported from Arthur
add_action( "propertyhive_property_unit_imported_arthur_json", 'use_unit_ref_as_post_title', 10, 2 );
function use_unit_ref_as_post_title($post_id, $unit)
{
$new_title = '';
if ( isset($unit['unit_ref']) && $unit['unit_ref'] != '' )
{
$new_title = $unit['unit_ref'];
}
else{
return;
}
$my_post = array(
'ID' => $post_id,
'post_title' => wp_strip_all_tags( $new_title ),
);
// Update the post into the database
$post_id = wp_update_post( $my_post, true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment