I've registered post type with following --

$holidayLabels = array(
    'name' => __( 'Holidays'),
    'singular_name' => __( 'Holidays'),
    'all_items' => __( 'All Holidays'),
    'add_new' => __( 'Add New Holiday'),
    'add_new_item' => __( 'Add New Holiday'),
    'edit_item' => __( 'Edit Holiday'),
    'new_item' => __( 'New Holiday'),
    'view_item' => __( 'View Holidays'),
    'not_found' => __( 'No Holidays found'),
    'not_found_in_trash' => __( 'No Holidays found in Trash'),
    'parent_item_colon' => ''

);

$holidayArgs = array(
    'labels'               => $holidayLabels,
    'public'               => true,
    'publicly_queryable'   => true,
    '_builtin'             => false,
    'show_ui'              => true,
    'query_var'            => true,
    'rewrite'              => array( "slug" => "holidays" ),
    'capability_type'      => 'post',
    'hierarchical'         => false,
    //'menu_position'        => 6,
    'supports'             => array( 'title'),
    'has_archive'          => false,
    'show_in_nav_menus'    => false,

);
register_post_type('holidays', $holidayArgs);

And I want to remove permalink that appears below title when I post new holiday or start editing existing one. enter image description here

I want to remove this because, holidays will be displayed in separate widget. I don't want admin to be able to see it as single post anyhow. There's no template defined for such.

  • Do you want them to have archive page and to be able to access them with permalink? – Krzysiek Dróżdż Aug 1 '13 at 18:46
  • @KrzysiekDróżdż no. that's why I want to remove permalink. There's no such page available. Holidays will be shown in widget itself and details with ajax in modal. – SachinGutte Aug 1 '13 at 18:50
  • So you should also take care of disabling permalinks, archives, and so on. Take a look at my answer ;) – Krzysiek Dróżdż Aug 1 '13 at 19:09
up vote 34 down vote accepted

Well, there is another way. And better, I guess.

You should look at register_post_type parameters. You should probably set them like this:

'public' => false,  // it's not public, it shouldn't have it's own permalink, and so on
'publicly_queryable' => true,  // you should be able to query it
'show_ui' => true,  // you should be able to edit it in wp-admin
'exclude_from_search' => true,  // you should exclude it from search results
'show_in_nav_menus' => false,  // you shouldn't be able to add it to menus
'has_archive' => false,  // it shouldn't have archive page
'rewrite' => false,  // it shouldn't have rewrite rules

If post type is not public, then you won't see this part of editor.

Well, one quick way would be to just hide the container div using CSS.

add_action('admin_head', 'wpds_custom_admin_post_css');
function wpds_custom_admin_post_css() {

    global $post_type;

    if ($post_type == 'post_type') {
        echo "<style>#edit-slug-box {display:none;}</style>";
    }
}
  • that's surely one way to do this. But I was wondering for admin filter or something. But this does work and thank you. – SachinGutte Aug 1 '13 at 18:43

You can also hide this area by placing a small JavaScript code to admin_footer hook.

<?php
add_action('admin_footer', function() {
  global $post_type;
  if ($post_type == 'your_post_type') {
    echo '<script> document.getElementById("edit-slug-box").outerHTML = ""; 
    </script>';
  });
}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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