php – WordPress – 精选图像Meta Box在自定义帖子类型上不显示
我刚刚创建了一个自定义的帖子类型,但由于某些原因,“特色图像”元框不会显示.
它确实显示在“帖子”的帖子类型. 我启用了缩略图的主题支持,并在我的自定义帖子类型代码中添加了以下代码. <?php function register_cpt_product() { $labels = array( 'name' => _x( 'Products','product' ),'singular_name' => _x( 'Product','add_new' => _x( 'Add New','add_new_item' => _x( 'Add New Product','edit_item' => _x( 'Edit Product','new_item' => _x( 'New Product','view_item' => _x( 'View Product','search_items' => _x( 'Search Products','not_found' => _x( 'No products found','not_found_in_trash' => _x( 'No products found in Trash','parent_item_colon' => _x( 'Parent Product:','menu_name' => _x( 'Products',); $args = array( 'labels' => $labels,'hierarchical' => false,'description' => 'Allows the user to create products','supports' => array( 'title','editor','thumbnail','revisions' ),'public' => true,'show_ui' => true,'show_in_menu' => true,'show_in_nav_menus' => true,'publicly_queryable' => true,'exclude_from_search' => false,'has_archive' => true,'query_var' => true,'can_export' => true,'rewrite' => true,'capability_type' => 'post' ); register_post_type( 'product',$args ); } add_action( 'init','register_cpt_product' ); ?> 奇怪的是,在列出我的帖子类型的条目的页面上,有一个名为Thumbnail的列. 任何人都知道发生了什么事 谢谢
确保您还在主题/插件中的某个地方完成了add_theme_support(‘post-thumbnails’),或者您的帖子类型在提供给上述函数的post类型列表中(第二个参数是一个可选的post类型数组)if您已经为每个帖子类型启用它.
看来,精选帖子的“屏幕选项”设置可以设置为隐藏/显示每个帖子类型.虽然它很遥远,但可能已被取消激活,尽管默认情况下应该激活它.还要检查post_type_supports(‘project’,’thumbnail’)的返回值,以确定设置是否按预期设置,这将指向与管理部分相关的问题. 特色帖子元框通过以下代码行添加到管理部分: if ( current_theme_supports( 'post-thumbnails',$post_type ) && post_type_supports( $post_type,'thumbnail' ) ) add_meta_box('postimagediv',__('Featured Image'),'post_thumbnail_meta_box',null,'side','low'); 也许您可以在主题/插件中运行if语句,并确保按照预期的方式返回true.如果是,您可能还需要检查编辑页面的来源,看看#postimagediv是否在标记中,但不显示. 更新: 我刚刚将以下代码粘贴在Twenty Eleven主题的functions.php的末尾,在WordPress 3.4.2安装中,没有插件被激活,它工作正常 – 类型显示,我能够看到帖子缩略图编辑屏幕中的元框. add_theme_support('post-thumbnails'); function setup_types() { register_post_type('mytype',array( 'label' => __('My type'),)); } add_action('init','setup_types'); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |