Source: Edit Slug Button Missing in WordPress
If somewhere in the code for a WordPress site there is a filter hooked to
post_link
that’s replacing the URL so that it no longer contains the%postname%
placeholder, WordPress will assume there’s nothing to edit. It will therefore output the permalink on the post edit screen without the edit button next to it, and the permalink’s slug won’t be editable.
My particular issue was caused by a conflict with my permalink placeholder replacement script. I'd naively edited Add Custom Taxonomy Tags to Your WordPress Permalinks to run across the whole theme and catch any and all placeholders.
As per James White's comment, my issue was easily solved by excluding %my_custom_post_type_name%
(for custom post types) and %postname
(for regular post types).
A far more robust solution was to roll the script back to its initial state, bundle it with a plugin, and only target the specific placeholders which I knew that plugin needed to replace.
The following combination also works:
Settings > Permalinks > Common Settings: Post name
Setting the slug when registering the Custom Post Type:
register_post_type(
'tourdiaries',
array(
'labels' => $labels, // ...
'description' => 'Tour Diary entries',
'public' => true,
'exclude_from_search' => false,
'menu_position' => 5,
'menu_icon' => 'dashicons-book',
'capability_type' => 'post',
'supports' => array(
'title',
'editor',
'excerpt',
'custom-fields',
'thumbnail',
'comments',
'revisions',
),
'has_archive' => 'tourdiaries',
'rewrite' => array(
'slug' => 'tourdiaries/%wpdtrt_tourdates_taxonomy_tour%/%wpdtrt_tourdates_cf_daynumber%',
'with_front' => false,
'pages' => false,
),
);
);