Mình mua 1 theme trong đó có khai báo post type "property" rồi. Nhưng khi dùng plugin chẳng hạn Automatic Post tagged thì báo là post type "property" chưa registerred. Check if ( post_type_exists( ‘property’ ) ) { echo ’.....’; } thì đúng là chưa đăng ký.

Vậy làm thế nào để register cho post type này?

Đoạn code từ theme đã đăng ký như sau:

if( !function_exists( 'create_property_post_type' ) ){
function create_property_post_type(){

$labels = array(
'name' => __( 'Properties','framework'),
'singular_name' => __( 'Property','framework' ),
'add_new' => __('Add New','framework'),
'add_new_item' => __('Add New Property','framework'),
'edit_item' => __('Edit Property','framework'),
'new_item' => __('New Property','framework'),
'view_item' => __('View Property','framework'),
'search_items' => __('Search Property','framework'),
'not_found' => __('No Property found','framework'),
'not_found_in_trash' => __('No Property found in Trash','framework'),
'parent_item_colon' => ''
);

$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'has_archive' => true,
'capability_type' => 'post',
'hierarchical' => true,
'menu_icon' => 'dashicons-building',
'menu_position' => 5,
'supports' => array('title','editor','thumbnail','revisions','au thor','page-attributes','excerpt'),
'rewrite' => array( 'slug' => __('property', 'framework') )
);

register_post_type('property',$args);

}
}
add_action('init', 'create_property_post_type');

Cảm ơn rất nhiều cho bất kỳ lời khuyên nào.