我正在尝试将另一个字段(副标题)添加到我已经创建和现有的自定义post\\u类型:team(我的*子主题中的functions.php中的代码)
<?php
/**
* Custom Post type register framework
*/
include(get_stylesheet_directory(). \'/inc/acpt/init.php\');
add_action(\'init\', \'makethem\');
function makethem() {
$args = array(
\'supports\' => array( \'title\', \'editor\', \'page-attributes\', \'thumbnail\', \'excerpt\' ),
\'hierarchical\' => true,
);
$team = new post_type(\'team\',\'team\', false, $args );
}
/**
* Initialize the metabox class
*/
add_action( \'init\', \'be_initialize_team_meta_boxes\', 9999 );
function be_initialize_team_meta_boxes() {
if ( !class_exists( \'team_Meta_Box\' ) ) {
require_once( get_stylesheet_directory(). \'/inc/metaboxes/fisio-metaboxes.php\' );
require_once( get_stylesheet_directory(). \'/inc/metaboxes/init.php\' );
}
}
?>
这是fisio元数据库中的代码。php
<?php
/**
* Include and setup custom metaboxes and fields.
*
* @category YourThemeOrPlugin
* @package Metaboxes
* @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
* @link https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress
*/
/**
* Define the metabox and field configurations.
*
* @param array $meta_boxes
* @return array
*/
add_filter( \'team_Meta_Box\', \'team_sample_metaboxes\' );
function team_sample_metaboxes( array $meta_boxes ) {
$prefix = \'_team_\';
$meta_boxes[] = array(
\'id\' => \'team_details\',
\'title\' => \'Team details\',
\'post_type\' => \'team\', // Post type
\'context\' => \'side\',
\'priority\' => \'high\',
\'show_names\' => true, // Show field names on the left
\'fields\' => array(
array(
\'name\' => \'Subtitle\',
//\'desc\' => \'\',
\'id\' => $prefix . \'subtitle\',
\'type\' => \'text\'
),
),
);
return $meta_boxes;
}
add_action( \'init\', \'team_initialize_team_meta_boxes\', 9999 );
/**
* Initialize the metabox class.
*/
function team_initialize_team_meta_boxes() {
if ( ! class_exists( \'team_Meta_Box\' ) )
require_once get_stylesheet_directory(). \'/inc/metaboxes/init.php\';
}
问题是,当在wp admin i whant中添加新团队的post\\u类型post时,post\\u类型没有subtitle字段
我错过了什么?
编辑:如果你没有注意到我以前从未这样做过。我正在跟踪this steps 没有成功。。
-编辑-
我也在这样尝试:
$meta_boxes[] = array(
\'id\' => \'team_details\',
\'title\' => \'Team details\',
\'pages\' => \'team\', // Post type
\'context\' => \'normal\',
\'priority\' => \'high\',
\'show_names\' => true, // Show field names on the left
\'fields\' => array(
array(
\'name\' => \'Subtitle\',
\'desc\' => \'This is the subtitle\',
\'id\' => $prefix . \'subtitle\',
\'type\' => \'text\'
),
),
);
-编辑-
还尝试将post\\u类型作为数组传递
\'pages\' => array(\'team\'), // Post type