Skip to content

Instantly share code, notes, and snippets.

@JeremyEnglert
Created April 6, 2019 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeremyEnglert/4d85064a239ed611ce28d65b359fe84d to your computer and use it in GitHub Desktop.
Save JeremyEnglert/4d85064a239ed611ce28d65b359fe84d to your computer and use it in GitHub Desktop.
Remove slug from WP CPT
<?php
function remove_diets_slug($post_link, $post, $leavename) {
if (!in_array($post->post_type, array('mat_diets')) || 'publish' != $post->post_status)
return $post_link;
$post_link = str_replace('/diets/', '/', $post_link);
return $post_link;
}
add_filter('post_type_link', 'remove_diets_slug', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment