Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function repairman_permalink( $post_link, $post ) {
- if ( is_object( $post ) && $post->post_type == 'repairman' ) {
- $terms = wp_get_object_terms( $post->ID, 'city' );
- if( $terms ) {
- $term_slug = urldecode( $terms[0]->slug );
- return str_replace( '%city%', $term_slug, $post_link );
- }
- }
- return $post_link;
- }
- add_filter( 'post_type_link', 'repairman_permalink', 9, 2 );
- function repairman_permalink_structure( $post_link, $post ) {
- if ( is_object( $post ) && $post->post_type == 'repairman' ) {
- $terms = wp_get_object_terms( $post->ID, 'city' );
- if( is_array( $terms ) && ! empty( $terms ) ) {
- $term_slug = urldecode( $terms[0]->slug );
- return home_url( 'майстори/' . $term_slug . '/' . $post->post_name . '/' );
- }
- }
- return $post_link;
- }
- add_filter( 'post_type_link', 'repairman_permalink_structure', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement