【发布时间】:2014-08-29 19:40:04
【问题描述】:
尝试将自定义元框添加到 wordpress 中的自定义帖子类型,但似乎没有任何效果。
当我从教程中复制并粘贴整个代码 sn-p 时,它工作得很好。当我尝试将其添加到我已经制作的自定义帖子类型中时,我什么也没得到。页面没有中断,自定义元框只是不显示。当我把头发拉出来时,希望得到一些帮助。
此时,我只想在帖子编辑界面中显示该死的东西!
// 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');
}
【问题讨论】:
标签: php wordpress wordpress-theming custom-post-type