The default post types are post, page, attachment, revision, and nav_menu_item.
Replace ‘post_type’ with ‘post’:
add_action('admin_head', 'wpds_custom_admin_post_css');
function wpds_custom_admin_post_css() {
global $post_type;
if ($post_type == 'post') {
echo "<style>#edit-slug-box {display:none;}</style>";
}
}
If you want to remove it for multiple post types (i.e. post, page, or any custom post types you might have), change line #6 above:
if ( in_array($post_type, array( 'post', 'page', 'your_own_post_type' )) ) {
If you only want to remove it from posts for non-admins, change line #6 above:
if ( ($post_type == 'post') && (! current_user_can( 'administrator' )) ) {
Additionally, if you want to remove the slug meta box for posts, add:
add_action( 'admin_menu', 'custom_remove_meta_boxes' );
function custom_remove_meta_boxes() {
if ( ! current_user_can( 'administrator' ) ) {
remove_meta_box('slugdiv', 'post', 'normal');
}
}