Trying to add a custom meta box to a custom post type in wordpress and nothing seems to work.

When I copy and paste a whole code snippet from tutorials it works just fine. When I try and add it to my already made custom post type, I get nothing. The page doesn’t break, the custom meta box just doesn’t display. Would love some help as I’m pulling my hair out.

At this point, I just want the darn thing to show up in the post editing interface!

// Register Custom Post Type
function generate_shows() {
  $labels = array(
    'name'                => _x( 'Shows', 'Post Type General Name', 'text_domain' ),
    'singular_name'       => _x( 'Show', 'Post Type Singular Name', 'text_domain' ),
    'menu_name'           => __( 'Shows', 'text_domain' ),
    'parent_item_colon'   => __( 'Parent Item:', 'text_domain' ),
    'all_items'           => __( 'All Shows', 'text_domain' ),
    'view_item'           => __( 'View Item', 'text_domain' ),
    'add_new_item'        => __( 'Add New Show', 'text_domain' ),
    'add_new'             => __( 'Add New', 'text_domain' ),
    'edit_item'           => __( 'Edit Item', 'text_domain' ),
    'update_item'         => __( 'Update Item', 'text_domain' ),
    'search_items'        => __( 'Search Shows', 'text_domain' ),
    'not_found'           => __( 'Not found', 'text_domain' ),
    'not_found_in_trash'  => __( 'Not found in Trash', 'text_domain' )
  );
  $args = array(
    'label'               => __( 'enk_show', 'text_domain' ),
    'description'         => __( 'An individual ENK Shows', 'text_domain' ),
    'labels'              => $labels,
    'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ),
    'taxonomies'          => array( 'category', 'post_tag' ),
    'hierarchical'        => true,
    'rewrite'             => array( 'slug' => 'shows', 'with_front' => false ),
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 5,
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'register_meta_box_cb' => 'add_enk_metaboxes',
    'capability_type'     => 'post'
  );
  register_post_type( 'enk_show', $args );
}
// Hook into the 'init' action
add_action( 'init', 'generate_shows', 0 );
// Add the Events Meta Boxes
function add_enk_metaboxes() {
  add_meta_box('wpt_events_location', 'Event Location', 'wpt_events_location', 'events', 'side', 'default');
}

Read more here: Can’t Add Custom Meta Box to Custom Post Type


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , ,

Wordpress related questions and answers: