Slide 22
Slide 22 text
The WordPress Way: register_post_type & register_meta
function register_locations {
register_post_type( 'locations',
array(
'labels' => array(
'name' => __( 'Locations' ),
'singular_name' => __( 'Location' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'locations'),
)
);
}
add_action( ‘init’, ‘register_locations’);
register_post_type
https://codex.wordpress.org/Function_Reference/register_post_type/
register_meta
$args = array(
'sanitize_callback' => 'sanitize_my_meta_key',
'auth_callback' => 'authorize_my_meta_key',
'type' => 'string',
'description' => ‘Enter Address',
'single' => true,
'show_in_rest' => true,
);
register_meta( 'locations', ‘street_address’, $args );
https://codex.wordpress.org/Function_Reference/register_meta/