2017-10-12 147 views

回答

0

好的,我不知道我是否让你100%正确...你改变了默认“post”的名称和附加值!?

也许会更好引进了自定义后类型为,但正如之前所说的,不会与子菜单中更改问题...

如果你的客户为例想要这样的说法,在这里我们走了,我测试了这个解决方案,它工作得很好,当然,你可能需要做一些造型:

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'); 

我将此代码添加到我的functions.php这个感动“类别”和的“标签”在“dashbord”之前,将帖子类型“帖子”添加到管理菜单的顶部!

如果你的“仪表板”后,希望尝试使用:

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'); 

如果您使用的不是帖子型“上岗”你必须改变选择“#菜单的帖子”,只是看它在检查员!

编辑关于你的最后一页评论:

如果你想要做一些造型永远不要改变WordPress的核心管理,CSS,你将失去每WordPress的更新这些变化!

但是你可以CSS以同样的方式就像我们所插入的脚本等,即通过CSS背景添加一个图标像这样通过你的函数中插入样式:

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'); 

第二件事:重命名...正如前面提到的,我不会改变帖子类型“发布”,更好的做法是引入一个自定义帖子类型,你可以根据你的需要和他们的分类法命名它们,但我想你不想改变那现在,我们又一次用JS的“不洁的hack-like”方式......全码:

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'); 

在这里你可以看到在行动的整个事情:

working example

+0

Ups,我刚刚注意到,以这种方式改变了分类和标签的顺序,试着避免这种情况:jQuery(“#menu-posts ul li:nth-​​of型(5) “)insertAfter(” #菜单的仪表板“); jQuery(“#menu-posts ul li:nth-​​of-type(4)”)。insertAfter(“#menu-dashboard”); – ToTaTaRi

+0

非常有帮助,非常感谢...我想知道是否有添加图标和编辑字体的方式,因为我尝试在wp-admin/css/admin-menu.css中执行该操作,但没有任何更改! –

+0

还有一件重要的事情:如何重命名它们? –

0

,您可以更改高会出现一个菜单,但我敢肯定,你不能改变一个子菜单的水平,因为例如这些类别属于帖子类型“帖子”,因为每个分类法属于它们被定义的帖子类型...

您可以设置otion网页,或自定义文章类型,但第一个也不会inculde分类,第二个不是直接的,也只是作为一个子菜单...

无论如何,也许你能做到所以用java脚本改变管理屏幕的dom,但我不会推荐这样做!这项任务是否有特定的原因?

+0

在这里,您可以看到如何包括管理屏幕上的自定义JS: HTTPS://codex.wordpress .org/Plugin_API/Action_Reference/admin_enqueue_scripts 因此,你可以添加一个脚本,“移动”的链接,即通过jquery ......但正如我所说我不会推荐这个,因为它不会让我觉得这么多sence! – ToTaTaRi

+0

Txs为您的答案。我添加了一张图片,解释了我在下面说的 –

相关问题