Saving property custom fields

We set up a property as a custom post type and hence the main property details will be saved automatically on property publication or update events. However, custom field data will not be saved in this process, and hence we need a custom implementation to store these data. We have chosen to store the custom field data in the wp_postmeta table. Let's look at the process of saving custom fields using the WordPress save_post action. First, we need to add the following line of code to the constructor of the WQCPT_Model_Property class:

add_action( 'save_post', array( $this, 'save_property_meta_data' ) );

This action is triggered whenever we create or update a post or custom post type. Now, we have to implement the ...

Get WordPress Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.