Custom post type not being targeted
-
I just installed the plugin on my site that uses a custom post type. I have added some checklist items and I see them on the generic post editor. However I have selected the custom post type on this screen:
/wp-admin/admin.php?page=ppch-settingsand clicked save. But when I create a new post of that custom type, the checklist interface is missing.Can you tell me what I am doing wrong? What should I do to troubleshoot this? I have debugging on and there are no errors.
The checklists I have added are:
- number of characters in excerpt (50-250)
- Feature image is added
The custom post type has both excerpts and featured images options
The following is the custom code that creates the custom post type:
/*
/
/
Custom Post Type CDF Events
/
/
*/
add_action( 'init', 'cdf_events_register_post_type' );
function cdf_events_register_post_type() {
$args = [
'label' => esc_html__( 'CDF Events', 'text-domain' ),
'labels' => [
'menu_name' => esc_html__( 'CDF Events', 'cdf-serene' ),
'name_admin_bar' => esc_html__( 'CDF Event', 'cdf-serene' ),
'add_new' => esc_html__( 'Add CDF Event', 'cdf-serene' ),
'add_new_item' => esc_html__( 'Add new CDF Event', 'cdf-serene' ),
'new_item' => esc_html__( 'New CDF Event', 'cdf-serene' ),
'edit_item' => esc_html__( 'Edit CDF Event', 'cdf-serene' ),
'view_item' => esc_html__( 'View CDF Event', 'cdf-serene' ),
'update_item' => esc_html__( 'View CDF Event', 'cdf-serene' ),
'all_items' => esc_html__( 'All CDF Events', 'cdf-serene' ),
'search_items' => esc_html__( 'Search CDF Events', 'cdf-serene' ),
'parent_item_colon' => esc_html__( 'Parent CDF Event', 'cdf-serene' ),
'not_found' => esc_html__( 'No CDF Events found', 'cdf-serene' ),
'not_found_in_trash' => esc_html__( 'No CDF Events found in Trash', 'cdf-serene' ),
'name' => esc_html__( 'CDF Events', 'cdf-serene' ),
'singular_name' => esc_html__( 'CDF Event', 'cdf-serene' ),
],
'public' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'show_in_rest' => true,
'capability_type' => 'post',
'hierarchical' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite_no_front' => false,
'show_in_menu' => true,
'menu_position' => 6,
'menu_icon' => 'dashicons-calendar-alt',
'supports' => [
'title',
'editor',
'author',
'thumbnail',
'excerpt',
'comments',
'revisions',
'page-attributes',
],
'rewrite' => true
];
register_post_type( 'events', $args );
}
add_action( 'init', 'cdf_register_custom_post_statuses', 11 );
function cdf_register_custom_post_statuses() {
register_post_status( 'cancelled', [
'label' => _x( 'Cancelled', 'post' ),
'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>' ),
'public' => false,
'internal' => false,
'exclude_from_search' => true,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'show_in_rest' => true, // ✅ REQUIRED for Gutenberg
'post_type' => [ 'events' ],
] );
register_post_status( 'on-hold', [
'label' => _x( 'On Hold', 'post' ),
'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>' ),
'public' => false,
'internal' => false,
'exclude_from_search' => true,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'show_in_rest' => true, // ✅ REQUIRED for Gutenberg
'post_type' => [ 'events' ],
] );
}
// Register Custom Taxonomy Events Categories
add_action( 'init', 'category_events_taxonomy', 0 );
function category_events_taxonomy() {
$labels = array(
'name' => _x( 'Events Categories', 'Taxonomy General Name', 'text_domain' ),
'singular_name' => _x( 'Event Category', 'Taxonomy Singular Name', 'text_domain' ),
'menu_name' => __( 'Event Category', 'text_domain' ),
'all_items' => __( 'All Events', 'text_domain' ),
'parent_item' => __( 'Parent Event', 'text_domain' ),
'parent_item_colon' => __( 'Parent Event:', 'text_domain' ),
'new_item_name' => __( 'New Event Category', 'text_domain' ),
'add_new_item' => __( 'Add Event Category', 'text_domain' ),
'edit_item' => __( 'Edit Event Category', 'text_domain' ),
'update_item' => __( 'Update Event Category', 'text_domain' ),
'view_item' => __( 'View Event Category', 'text_domain' ),
'separate_items_with_commas' => __( 'Separate Event with commas', 'text_domain' ),
'add_or_remove_items' => __( 'Add or remove Event Categories', 'text_domain' ),
'choose_from_most_used' => __( 'Choose from the most used', 'text_domain' ),
'popular_items' => __( 'Popular Event Categories', 'text_domain' ),
'search_items' => __( 'Search Items', 'text_domain' ),
'not_found' => __( 'Not Found', 'text_domain' ),
'no_terms' => __( 'No events', 'text_domain' ),
'items_list' => __( 'Events list', 'text_domain' ),
'items_list_navigation' => __( 'Events list navigation', 'text_domain' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'exclude_from_search' => false,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => false,
'show_in_rest' => true,
'has_archive' => true,
'args' => array( 'orderby' => 'term_order' ),
'rewrite' => array( 'slug' => 'event-category', 'with_front' => false ),
'query_var' => true
);
register_taxonomy( 'event_category', 'events', $args );
}
The topic ‘Custom post type not being targeted’ is closed to new replies.