Wordpress:将管理子菜单从帖子移动到父级
我现在想知道是否有任何方法可以将管理子菜单分类(作为类别和标记)的级别从POST更改为父菜单(例如页面、注释…)Wordpress:将管理子菜单从帖子移动到父级,wordpress,menu,taxonomy,submenu,wp-admin,Wordpress,Menu,Taxonomy,Submenu,Wp Admin,我现在想知道是否有任何方法可以将管理子菜单分类(作为类别和标记)的级别从POST更改为父菜单(例如页面、注释…) 您可以更改菜单的显示高度,但我确信您不能更改子菜单的级别,因为例如,类别属于post类型“post”,因为每个分类法都属于定义它们的post类型 您可以设置otion页面或自定义帖子类型,但第一个不会包含分类法,第二个不会直接包含,也只是作为子菜单 无论如何,也许你可以用java脚本来改变管理员屏幕的dom,但我不推荐这样做!这项任务有什么特别的原因吗?好的,我不知道我是否100%
您可以更改菜单的显示高度,但我确信您不能更改子菜单的级别,因为例如,类别属于post类型“post”,因为每个分类法都属于定义它们的post类型 您可以设置otion页面或自定义帖子类型,但第一个不会包含分类法,第二个不会直接包含,也只是作为子菜单
无论如何,也许你可以用java脚本来改变管理员屏幕的dom,但我不推荐这样做!这项任务有什么特别的原因吗?好的,我不知道我是否100%正确。。。您更改了默认“帖子”的名称和外观 也许引入一个自定义的post类型会更好,但这不会改变之前提到的子菜单的问题 如果您的clinet希望如此,那么我们开始吧,我测试了此解决方案,效果很好,当然您可能需要进行一些造型:
function load_custom_wp_admin_style() { ?>
<script>
jQuery("#menu-posts ul li:nth-of-type(4)").prependTo("#adminmenu");
jQuery("#menu-posts ul li:nth-of-type(4)").prependTo("#adminmenu");
</script>
<?php }
add_action( 'admin_footer', 'load_custom_wp_admin_style' );
function load\u custom\u wp\u admin\u style(){?>
jQuery(#menu posts ul li:nth类型(4)”).prependTo(#adminmenu);
jQuery(#menu posts ul li:nth类型(4)”).prependTo(#adminmenu);
jQuery(“#菜单张贴ul li:nth类型(4)”)。插入后面(#菜单面板”);
jQuery(“#菜单张贴ul li:nth类型(4)”)。插入后面(#菜单面板”);
在这里,您可以看到如何在管理屏幕上包含自定义js:这样您就可以添加一个“移动”的脚本链接,即通过jquery…但正如我所说,我不建议这样做,因为我认为这没有多大意义!Txs为您的答案。我添加了一张图片,解释了我下面所说的内容。另外,我刚刚注意到,通过这种方式,您可以更改类别和标记的顺序,尝试这样做以避免:jquery(“菜单张贴ul li:nth类型(5)”。插入后面(“#菜单仪表板”);jQuery(#菜单张贴ul li:nth类型(4)”。插入后面(#菜单仪表板”);非常有用,非常感谢……我想知道是否有办法添加图标和编辑字体,因为我尝试在wp admin/css/admin-menu.css中这样做,但没有任何更改!!!还有一件更重要的事情:如何重命名它们?要更改字体,您现在还可以使用此选择器:#自定义链接,#自定义标记链接{字体大小:…}或者您直接选择链接,即使用#custom_cat_link a{…},但是您可能必须添加!重要语句,在某些情况下,例如使用边距和填充来覆盖wp默认值…Txs很多,我已经解决了它
function load_custom_wp_admin_style() { ?>
<script>
jQuery("#menu-posts ul li:nth-of-type(4)").insertAfter("#menu-dashboard");
jQuery("#menu-posts ul li:nth-of-type(4)").insertAfter("#menu-dashboard");
</script>
<?php }
add_action( 'admin_footer', 'load_custom_wp_admin_style' );
function load_custom_wp_admin_style() { ?>
<script>
// I add an id to the element so it can be selected more easily for styling...
jQuery("#menu-posts ul li:nth-of-type(5)").attr('id', 'custom_tag_link');
// Here I change the position as done before...
jQuery("#menu-posts ul li:nth-of-type(5)").insertAfter("#menu-dashboard");
jQuery("#menu-posts ul li:nth-of-type(4)").attr('id', 'custom_cat_link');
jQuery("#menu-posts ul li:nth-of-type(4)").insertAfter("#menu-dashboard");
</script>
<style>
/* Here comes the styling... */
/* Do some margins/paddings and background-alignments... */
#custom_cat_link, #custom_tag_link {
background-size: auto 100%;
background-repeat: no-repeat;
padding-left: 25px !important;
margin: 10px !important;
}
/* Set your Icons here... */
#custom_cat_link {
background-image: url('https://cdn0.iconfinder.com/data/icons/customicondesignoffice5/256/examples.png');
}
#custom_tag_link {
background-image: url('https://cdn0.iconfinder.com/data/icons/customicondesignoffice5/256/examples.png');
}
</style>
<?php }
add_action( 'admin_footer', 'load_custom_wp_admin_style' );
function load_custom_wp_admin_style() { ?>
<script>
// I add an id to the element so it can be selected more easily for styling...
jQuery("#menu-posts ul li:nth-of-type(5)").attr('id', 'custom_tag_link');
// Change the name of the <a>-element in the <li>-elem here...
jQuery("#menu-posts ul li:nth-of-type(5) a").html('NEW TAG TITLE');
// Here I change the position as done before...
jQuery("#menu-posts ul li:nth-of-type(5)").insertAfter("#menu-dashboard");
jQuery("#menu-posts ul li:nth-of-type(4)").attr('id', 'custom_cat_link');
jQuery("#menu-posts ul li:nth-of-type(4) a").html('NEW CAT TITLE');
jQuery("#menu-posts ul li:nth-of-type(4)").insertAfter("#menu-dashboard");
</script>
<style>
/* Here comes the styling... */
/* Do some margins/paddings and background-alignments... */
#custom_cat_link, #custom_tag_link {
background-size: auto 100%;
background-repeat: no-repeat;
padding-left: 25px !important;
margin: 10px !important;
}
/* Set your Icon here... */
#custom_cat_link {
background-image: url('https://cdn0.iconfinder.com/data/icons/customicondesignoffice5/256/examples.png');
}
#custom_tag_link {
background-image: url('https://cdn0.iconfinder.com/data/icons/customicondesignoffice5/256/examples.png');
}
</style>
<?php }
add_action( 'admin_footer', 'load_custom_wp_admin_style' );