The available_permalink_structure_tags WordPress PHP filter allows you to modify the list of available permalink structure tags on the Permalinks settings page.
Usage
add_filter('available_permalink_structure_tags', 'my_custom_permalink_tags'); function my_custom_permalink_tags($available_tags) { // your custom code here return $available_tags; }
Parameters
$available_tags
(string[]): An array of key => value pairs of available permalink structure tags.
More information
See WordPress Developer Resources: available_permalink_structure_tags
Examples
Add a custom permalink tag
Add a custom permalink tag %my_custom_tag%
to the list of available permalink structure tags.
add_filter('available_permalink_structure_tags', 'add_my_custom_permalink_tag'); function add_my_custom_permalink_tag($available_tags) { $available_tags['my_custom_tag'] = __('My Custom Tag'); return $available_tags; }
Remove a specific permalink tag
Remove the %year%
permalink tag from the list of available permalink structure tags.
add_filter('available_permalink_structure_tags', 'remove_year_permalink_tag'); function remove_year_permalink_tag($available_tags) { unset($available_tags['year']); return $available_tags; }
Replace a permalink tag description
Replace the description of the %post_id%
permalink tag.
add_filter('available_permalink_structure_tags', 'replace_post_id_tag_description'); function replace_post_id_tag_description($available_tags) { $available_tags['post_id'] = __('Custom Post ID Description'); return $available_tags; }
Add multiple custom permalink tags
Add multiple custom permalink tags to the list of available permalink structure tags.
add_filter('available_permalink_structure_tags', 'add_multiple_custom_permalink_tags'); function add_multiple_custom_permalink_tags($available_tags) { $available_tags['custom_tag_1'] = __('Custom Tag 1'); $available_tags['custom_tag_2'] = __('Custom Tag 2'); return $available_tags; }
Clear all available permalink tags
Remove all available permalink structure tags.
add_filter('available_permalink_structure_tags', 'clear_all_permalink_tags'); function clear_all_permalink_tags($available_tags) { return array(); }