我正在尝试通过子主题注册帖子类型function.php
但它不起作用。但是,当我添加父项时,效果很好functions.php
.
add_action( \'init\', \'testimonial\' );
if ( ! function_exists( \'testimonial\' ) ) :
function testimonial() {
register_post_type( \'testimonial\',
array(
\'labels\' => array(
\'name\' => \'Testimonial\',
\'singular_name\' => \'Testimonial\',
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New Testimonial\',
\'edit\' => \'Edit\',
\'edit_item\' => \'Edit Testimonial\',
\'new_item\' => \'New Testimonial\',
\'view\' => \'View\',
\'view_item\' => \'View Testimonial\',
\'search_items\' => \'Search Testimonial\',
\'not_found\' => \'No Testimonial found\',
\'not_found_in_trash\' => \'No Testimonial found in Trash\',
\'parent\' => \'Parent Testimonial\'
),
\'public\' => true,
\'menu_position\' => 15,
\'supports\' => array( \'title\', \'editor\', \'comments\', \'thumbnail\', \'custom-fields\' ),
\'taxonomies\' => array( \'\' ),
//\'menu_icon\' => \'T\',
\'menu_icon\' => plugins_url().\'/images/testimonial.png\',
\'has_archive\' => true
)
);
}
endif;
有谁能指导我吗?我可以通过子主题注册post\\u类型吗
function.php
? 我会很感激的。谢谢
SO网友:Sheldon Alag
尝试检查您的功能。该函数可能存在于代码中的某个位置。如果找不到,请尝试删除if
语句,然后像这样直接添加函数
function testimonial() {
register_post_type( \'testimonial\',
array(
\'labels\' => array(
\'name\' => \'Testimonial\',
\'singular_name\' => \'Testimonial\',
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New Testimonial\',
\'edit\' => \'Edit\',
\'edit_item\' => \'Edit Testimonial\',
\'new_item\' => \'New Testimonial\',
\'view\' => \'View\',
\'view_item\' => \'View Testimonial\',
\'search_items\' => \'Search Testimonial\',
\'not_found\' => \'No Testimonial found\',
\'not_found_in_trash\' => \'No Testimonial found in Trash\',
\'parent\' => \'Parent Testimonial\'
),
\'public\' => true,
\'menu_position\' => 15,
\'supports\' => array( \'title\', \'editor\', \'comments\', \'thumbnail\', \'custom-fields\' ),
\'taxonomies\' => array( \'\' ),
//\'menu_icon\' => \'T\',
\'menu_icon\' => plugins_url().\'/images/testimonial.png\',
\'has_archive\' => true
)
);
}
add_action( \'init\', \'testimonial\' );