Created
April 7, 2022 19:55
-
-
Save nathaningram/b6aff36f3d0cd48873a41519061935c3 to your computer and use it in GitHub Desktop.
Remove Slug from CPT URLs
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
| //Removes Slugs from CPT URLs | |
| function na_remove_slug( $post_link, $post, $leavename ) { | |
| if ( 'linked_article' != $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', 'na_remove_slug', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment