Skip to content

Instantly share code, notes, and snippets.

@brianleejackson
Last active November 14, 2021 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brianleejackson/344b1df13cda62c2ade96a37b2da93bb to your computer and use it in GitHub Desktop.
Save brianleejackson/344b1df13cda62c2ade96a37b2da93bb to your computer and use it in GitHub Desktop.
Alternative way to remove the base slug from custom post type URL. Source: https://woorkup.com/wordpress-custom-post-type/
function bis_remove_cpt_slug($args, $post_type) {
if(in_array($post_type, array('artist'))) {
$args['rewrite'] = array('slug' => '/');
}
return $args;
}
add_filter('register_post_type_args', 'bis_remove_cpt_slug', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment