Created
April 26, 2019 11:17
-
-
Save munirkamal/b9db6dff8cb6ece83f02e58ecdfc612b to your computer and use it in GitHub Desktop.
My WP blog Rewrite Code
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 | |
function my_custom_pt_link( $post_link, $id = 0 ){ | |
$post = get_post($id); | |
if ( is_object( $post ) ){ | |
$terms = wp_get_object_terms( $post->ID, ‘abc ); | |
if( $terms ){ | |
return str_replace( ‘%abc%’ , $terms[0]->slug , $post_link ); | |
} else { | |
return str_replace( ‘%abc%’ , 'misc' , $post_link ); | |
} | |
} | |
return $post_link; | |
} | |
add_filter( 'post_type_link', 'my_custom_pt_link', 1, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment