I have a drop down select type field in Advanced Custom Fields. The values are Video and Image.
I want to replace the Custom post type slug. Currently, it is video.
I want to change mysite.com/video/post-name to mysite.com/1/post-name or mysite.com/0/post-name
I mean when the drop down value Video is selected, it will show mysite.com/1/post-name.
I can replace the post type slug.
function update_video_slug( $args, $post_type) {
$cptslug = "newslug";
if ( 'video' === $post_type ) {
$args['rewrite']['slug'] = $cptslug;
}
return $args;
}
add_filter( 'register_post_type_args', 'update_video_slug', 10, 2 );
Can be the $cptslug value dynamic according to ACF value?