Okay
  Print

Create property in database

https://gist.github.com/moometric/77bcd016a9445e349b981276a1072e8d

class new_listing {
  
  public $propertyData;
  
function __construct($propertyData = NULL) {
    $this->propertyData = $propertyData;
}

function Listing_CreateNewListing() {
  
$post_arr = array(
    'post_title'    => $this->propertyData['Address'],
    'post_content' => $this->propertyData['en_desc'],
    'post_status'  => 'publish',
    'post_type' => 'iwp_property',
    'post_author'  => get_current_user_id(),
    'meta_input'   => array(
        '_iwp_expiry' => strtotime($this->propertyData['ExpirationDate']),
        '_iwp_featured' => 0,
        '_iwp_price' => $this->propertyData['AskedSoldPrice'],
        '_iwp_property_id' => propertyData['listingid'],
        '_iwp_bedrooms' => $this->propertyData['Bedrooms'],
        '_iwp_bathrooms' => $this->propertyData['Bathrooms'],
        '_iwp_garages' => $this->propertyData['Garage'],
        '_iwp_area_size' => $this->propertyData['LivingAreaImperial'],
        '_iwp_land_size' => $this->propertyData['LotAreaImperial'],
        '_iwp_year_built' => $this->propertyData['YearBuilt'],
        '_iwp_address' => $this->propertyData['Address'],
        '_iwp_zip' => $this->propertyData['PostalCode'],
        '_iwp_longitude' => $this->propertyData['Lng'],
        '_iwp_latitude' => $this->propertyData['Lat'],
        '_iwp_map' => $this->propertyData['Lng'].','.$this->propertyData['Lat'].',14',
        '_iwp_contact_infomation' => 'hide',
        '_iwp_admin_review' => 2,
    ),
);
$this->postId = wp_insert_post($post_arr, true);

if (is_wp_error($this->postId)) {

foreach ($this->postId->error_data as $key => $value) {
echo "$key - $value";

}
}

return $this;
}
}

new new_listing($propertyData[])