Hi everybody,
I would like to know if there is a way to modify the slug of a Custom Post Type directly from an option page.
I have a field called “team” in my option page.
I tried with something like this but it doesn’t work. if someone has an idea…
function create_team()
{ $slugurl = the_field('splash_fadein', 'option');
$args = array(…
'rewrite' => array('slug' => $slugurl),…)
register_post_type('team',$args);
}
Best,
Damien
updating rewrite rules is a funny thing in WP and requires flushing the rewrite rules in key places. For example during plugin activation or deactivation. If you add rules after the cache has been created WP will not recognize them. For more information on this see the codex here https://codex.wordpress.org/Rewrite_API/flush_rules