Hi,
I have difficulties to rewrite the slug of a custom post type… Previously the CPT was named ‘conversations’ but I have to change it for ‘instruments’. I’ve made all the labelling changes but I can’t make the slug rewriting working properly. The url of the posts keep being https://www.xxxx.com/conversations/name-of-the-post (permalinks refreshed).
Please find my code below :
<?php
function elro_cpt_instruments() {
$labels = array(
'name' => 'Instruments',
'all_items' => 'Tous les Instruments',
'singular_name' => 'Instrument',
'add_new_item' => 'Ajouter un instrument',
'edit_item' => 'Modifier cet instrument',
'menu_name' => 'Instruments',
'rewrite' => array('slug' => 'instruments'),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_rest' => true,
'has_archive' => false,
'supports' => array( 'title', 'editor','thumbnail' ),
'menu_position' => 5,
'menu_icon' => 'dashicons-book-alt',
);
register_post_type( 'conversations', $args );
}
add_action( 'init', 'elro_cpt_instruments', 0 );
I could write a filter to do that but I’d prefer my slug rewriting to work into my CPT declaration.
What am I doing wrong?
Thanks by advance for your help!