Last active
October 24, 2024 10:36
-
-
Save g-maclean/4c61cf4950f33a36d4f229515a2be4b2 to your computer and use it in GitHub Desktop.
Use unit ref as title for unit imported from Arthur
This file contains hidden or 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
| 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