I want to now if there is any method to change level of an admin submenu taxonomy (as categories and tags) from Posts to make it as a parent menu (such as Page, Comment ...)
2 Answers
Ok, I don't know if I get you 100% right... You changed the name and appereance of the default "post"!?
Maybe it would have been better to introduce a custom post type for that, but that won't change the problem with the sub menu as said before...
If your clinet wants it that way, here we go, I tested this solution and it works fine, of course you may have to do some styling:
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' );
I added this code to my functions.php and this moved "categories" and "tags" of the post type "posts" to the top of the admin menu right before "dashbord"!
If you want it after the "dashboard" try to use:
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' );
If you are not using the post type "posts" you must change the selector "#menu-posts", just look it up in the inspector!
EDIT REGARDING TO YOUR LAST COMMENTS:
If you want to do some styling do not ever change the wordpress core admin-css, you will loose these changes on every wordpress update!!!
But you can insert styles via your function css the same way like we've inserted the script and so i.e. add an icon via css backgrounds like this:
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' );
Second thing: The renaming... As mentioned before I would've not changed the post type "post", better practice would have been to introduce a custom post type, you can name them as you want and also their taxonomies, but I guess you don't want to change that now, so again we go the "unclean hack-a-like" way with JS... Full code:
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' );
Here you can see the whole thing in action:

- 311
- 1
- 8
-
Ups, I just noticed, that in this way you change the order of Categories and Tags, try this to avoid that: jQuery("#menu-posts ul li:nth-of-type(5)").insertAfter("#menu-dashboard"); jQuery("#menu-posts ul li:nth-of-type(4)").insertAfter("#menu-dashboard"); – ToTaTaRi Oct 12 '17 at 14:29
-
very helpful, thanks a lot ...i wondering if there is a way to add an icon and edit the font, because i try to do that in wp-admin/css/admin-menu.css but nothing change !!! – piair jako Oct 12 '17 at 14:56
-
one more important thing: how to rename them? – piair jako Oct 12 '17 at 16:08
-
For changing the font you now can also use this selector: #custom_cat_link, #custom_tag_link {font-size:..} OR you directly select the links i.e. with #custom_cat_link a {...}, but you may have to add the !important-statement in some cases like it's done with margin and padding to override the wp-defaults... – ToTaTaRi Oct 13 '17 at 12:50
-
Txs a lot, i have already solve it – piair jako Oct 14 '17 at 11:56
You can change how high a menu will appear, but I'm quite sure that you can not change the level of a submenu, because for example the categories belong to the post type "post" as every taxonomy belongs to the post type on which they are defined...
You can set up otion pages, or custom post types, but the first one won't inculde taxonomies and the second one not directly, also just as a submenu...
Anyway, maybe you can do so with a java script hack changing the dom of the admin screen, but I wont recommend to do so! Is there a specific reason for that task?

- 311
- 1
- 8
-
Here you can see how to include custom js on admin screen: https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts So you could add a script which "moves" the links i.e. via jquery... But as I said i wont recommend this because it does not make that much sence in my opinion! – ToTaTaRi Oct 12 '17 at 10:11
-