Created
April 6, 2019 18:18
-
-
Save JeremyEnglert/4d85064a239ed611ce28d65b359fe84d to your computer and use it in GitHub Desktop.
Remove slug from WP CPT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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