我有这个代码用于创建自定义帖子类型
add_action( 'init', 'create_sidebarone' );
function create_sidebarone() {
register_post_type( 'sidebarone',
array(
'labels' => array(
'name' => 'Sidebar One',
'singular_name' => 'sidebarone',
'add_new' => 'Add New',
'add_new_item' => 'Add Sidebar One',
'edit' => 'Edit',
'edit_item' => 'Edit Sidebar One',
'new_item' => 'New Sidebar One',
'view' => 'View',
'view_item' => 'View Sidebar One',
'search_items' => 'Search Sidebar One',
'not_found' => 'No Sidebar One found',
'not_found_in_trash' => 'No Sidebar One found in Trash',
'parent' => 'Parent Sidebar One'
),
'public' => true,
'menu_position' => 15,
'supports' => array( 'title', 'editor', 'comments', 'thumbnail' ),
'taxonomies' => array( '' ),
'menu_icon' => get_template_directory_uri() . '/images/ggicon.png',
'has_archive' => true
)
);
}
现在我想实现满足我需求的东西,我想为我的自定义帖子类型创建自定义管理屏幕或设置页面,准确的请参考下图:
这是我从上面的代码创建的自定义帖子类型的图示
现在,我想自定义管理屏幕或该帖子类型的设置屏幕,如下图所示:
现在您可以看到,管理员屏幕或该帖子类型的设置屏幕已经自定义。 (第二张图片是我想要实现的,图像编辑的假设)
到目前为止,我尝试的是来自上面代码的第一张图片的帖子类型库。任何人,我打开任何建议,建议和想法。非常感谢你提前。
答案 0 :(得分:0)
执行此操作的最佳方法是创建plugin,然后您可以通过关注wordpress.org中的this guide来创建管理面板
请注意链接指南中的示例:
<?php
/** Step 2 (from text above). */
add_action( 'admin_menu', 'my_plugin_menu' );
/** Step 1. */
function my_plugin_menu() {
add_options_page( 'My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options' );
}
/** Step 3. */
function my_plugin_options() {
if ( !current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo '<div class="wrap">';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '</div>';
}
?>