Flushing the slug base has no effect and does not change

Question

I’m trying to change the actor slug base, but when refreshing the permalinks everything remains the same. I am using the following code that I found to achieve it:

function space_change_custom_taxonomy_slug_args( $taxonomy, $object_type, $args ){
    if( 'actor' == $taxonomy ){ // Instead of the "old-slug", add current slug, which you want to change.
        remove_action( current_action(), __FUNCTION__ );
        $args['rewrite'] = array( 'slug' => 'star' ); // Instead of the "new-slug", add a new slug name.
        register_taxonomy( $taxonomy, $object_type, $args );
    }
}
add_action( 'registered_taxonomy', 'space_change_custom_taxonomy_slug_args', 10, 3 );

The theme has the following register taxonomy:

// Now register the non-hierarchical taxonomy like tag
    register_taxonomy('actors','post', array(
        'hierarchical' => false,
        'labels' => $labels,
        'show_ui' => true,
        'show_admin_column' => true,
        'update_count_callback' => '_update_post_term_count',
        'query_var' => true,
        'show_in_rest' => true,
        'rewrite' => array( 'slug' => 'actor' )
    ));

I do not know what I’m doing wrong. And a doubt that I have. It is better to use this code in functions or use a url rewrite rule from .htaccess?

0
DrWho 8 months 2020-12-13T09:10:21-05:00 0 Answers 4 views 0

Leave an answer

Browse
Browse