创建自定义分类法时,请使用post 作为分类法的对象类型:
register_taxonomy(\'your_custom_taxonomy\', \'post\', $args);
新的自定义分类将显示在“
Posts“标签”下的子菜单。要更改此顺序,请将此代码添加到
functions.php
或插件文件):
add_filter(\'menu_order\', \'reorder_post_submenu\', 15);
function reorder_post_submenu($menu_order) {
global $submenu;
if (isset($submenu, $submenu[\'edit.php\'])) {
$i_offset = strlen(\'taxonomy=\');
$tmp_order = false;
foreach ($submenu[\'edit.php\'] as $key => &$value) {
$i_txm = strpos($value[2], \'taxonomy=\');
if ($i_txm === false)
continue;
$name = substr($value[2], $i_txm + $i_offset);
if ($name == \'post_tag\' ) {
// get last item key
$last = array_pop( array_keys($submenu[\'edit.php\']) );
// move "tag" menu item to the end
$submenu[\'edit.php\'][$last + 5] = $value;
unset($submenu[\'edit.php\'][$key]);
break;
}
}
}
return $menu_order;
}
“默认帖子”子菜单如下所示:
[edit.php] => Array (
// ["label", "capability", "page"]
[5] => Array (
[0] => All Posts
[1] => edit_posts
[2] => edit.php
)
[10] => Array (
[0] => Add New
[1] => edit_posts
[2] => post-new.php
)
[15] => Array (
[0] => Categories
[1] => manage_categories
[2] => edit-tags.php?taxonomy=category
)
[16] => Array (
[0] => Tags
[1] => manage_post_tags
[2] => edit-tags.php?taxonomy=post_tag
)
)