开发者

How do I add content types other than Posts in the WordPress admin area?

开发者 https://www.devze.com 2023-02-10 15:04 出处:网络
I want to add a completely custom content type to the WordPress admin panel as per my image below. I don\'t believe this is called a plugin as I did a tutorial on those and they don\'t have an admin i

I want to add a completely custom content type to the WordPress admin panel as per my image below. I don't believe this is called a plugin as I did a tutorial on those and they don't have an admin interface. I want to define a custom create/edit/delete screen for this content.

Is this possible? What should I be searching for to get help on thi开发者_如何学Cs?

How do I add content types other than Posts in the WordPress admin area?


I believe what you're looking for (as of Wordpress 3.0) is custom post types. There's quite a good tutorial on them here, however googling "wordpress custom post types" should provide a plethora of links.


http://codex.wordpress.org/Function_Reference/add_submenu_page is a good starting place to look. It will explain how to add new items into the menu.

Now, removing them is a different story. This function I wrote for one of my plugins removes entries from a submenu:

function cleanup_menu() {
    global $submenu, $wpdb;
    $new_submenu = array();

    $remove = array( 'Cast Manager', 'Seating Manager', 'Download Reports', 'new report' );

    foreach ($submenu['menuname'] as &$item) {
        if ( ! in_array( $item[0], $remove ) ) { $new_submenu[] = $item; }
    }

    $submenu['menuname'] = $new_submenu;
}

So in your case, "menuname" would be changed to "Posts", I would guess. There's also a function remove_submenu_page, but there's no documentation on it and I haven't looked into it.

0

精彩评论

暂无评论...
验证码 换一张
取 消