Created
November 6, 2015 02:39
-
-
Save kellenmace/1303be52a286610420d5 to your computer and use it in GitHub Desktop.
Remove custom post type slug from permalinks
This file contains hidden or 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 | |
/** | |
* Remove the slug from published post permalinks. Only affect our custom post type, though. | |
*/ | |
function gp_remove_cpt_slug( $post_link, $post, $leavename ) { | |
if ( 'race' != $post->post_type || 'publish' != $post->post_status ) { | |
return $post_link; | |
} | |
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link ); | |
return $post_link; | |
} | |
add_filter( 'post_type_link', 'gp_remove_cpt_slug', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment