Here is an interesting question.

I have recently noticed that if you utilize the code

remove_meta_box('slugdiv', 'post', 'normal'); 

you are actually unable to modify the slug when you click on the url slug under the page title.

To clarify, when you use remove_meta_box for the slugdiv, the metabox and the screen options get removed however you are still able to click on the url under the post title to edit it... However, when you go to update/publish the post whatever modification you made does not take.

My objective is to remove the same metabox from the post edit screen AND remove it from the screen options page BUT I want to ensure that when you edit the slug under the post title that this still works.

Can anyone provide a solution to this problem? Thanks in advance.

  • Hi @NetConstructor.com: I don't understand your question: "My objective is to remove the same metabox from the post edit screen AND remove it from the screen options page BUT I want to ensure that when you edit the slug under the post title that this still works." If you remove the field, how can you edit it? Can you reword? It's not clear at all to me. – MikeSchinkel Sep 21 '10 at 6:27
  • @MikeSchinkel -- I actually tried above. If you look at an existing post edit screen and look under the post title you will see a URL. If you click on the last part of the url you can edit it. What i am trying to do is remove the additional "SLUG" metabox and screen options but KEEP the one under the post title. Does that make sense? – NetConstructor.com Sep 21 '10 at 10:27
  • @NetConstructor - That's just a guess but please validate: Maybe this is only the case while you have your plugin running? Please verfiy with a new, clean install. – hakre Sep 21 '10 at 22:30
  • @MikeSchinkel -- I have done a fresh install of Wordpress and have noticed this is not related to the plugin. In other words, even with no plugins installed this still happens. Can you please confirm by removing the slug metabox and trying to update the slug by clicking the url under the title? – NetConstructor.com Sep 29 '10 at 8:49

The box which allows slug edition under the post title is actually tied to the slug metabox. It needs it to work. So, removing the metabox will break it.

The only solution, I think, would be to use javascript or css to hide it. Something like this will work:

function hide_slug_box() {
    global $post;
    global $pagenow;
    if (is_admin() && $pagenow=='post-new.php' OR $pagenow=='post.php') {
        echo "<script type='text/javascript'>
            jQuery(document).ready(function($) {
add_action( 'admin_head', 'hide_slug_box'  );

I ended up just adding the following CSS to a css file I was calling in my functions.php file for the admin area:

[for="slugdiv-hide"] { 
    display: none; 

#slugdiv { 
    display: none; 

This removed both the screen options and the metabox while still allowing me to edit the url under the title.


Based on the answer provided by FXFUTURE I modified his code by extending it and including the css values for screen options and the slug metabox while ensuring that the code only gets included on the post-new.php and post.php page.

   function hide_slug_options() {
    global $post;
    global $pagenow;
    $hide_slugs = "<style type=\"text/css\">#slugdiv, #edit-slug-box, [for=\"slugdiv-hide\"] { display: none; }</style>\n";
    if (is_admin() && $pagenow=='post-new.php' OR $pagenow=='post.php') print($hide_slugs);
   add_action( 'admin_head', 'hide_slug_options'  );
  • 1
    Quite old, but for future reference it seems these days you'll have to add !important for it to work. – user5424 Feb 13 '12 at 22:58

You should call remove_meta_box in the add_meta_boxes hook to get it working. It tested on 4.0.

add_action( 'add_meta_boxes', 'customize_admin_backend_cpt',0 );

function customize_admin_backend_cpt () {
    remove_meta_box( 'slugdiv', 'your_cpt_goes_here', 'normal' );

Rather than editing your css file you can use this in your functions.php:

function hide_all_slugs() {
global $post;
$hide_slugs = "<style type=\"text/css\"> #slugdiv, #edit-slug-box { display: none; }</style>";
add_action( 'admin_head', 'hide_all_slugs'  );
  • GREAT ANSWER! Do you buy chance know how to trick the system into actually removing the content instead of just hiding it without using the remove metabox function? I am essentially stuck in a situation where I would rather remove it than hide it but when I use the remove function I am unable to edit the slug when editing the url under the title. I can edit it but when I press save it just reverts to what it was before... Please let me know – NetConstructor.com Sep 30 '10 at 0:25
  • yes, you should call it in add_meta_boxes hook. Check latest example. – tolginho Aug 30 '14 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.