Created
April 4, 2016 14:49
-
-
Save jdcauley/144016061c841b7ddf44b6eb0a861dc4 to your computer and use it in GitHub Desktop.
custom slugs
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
add_filter( 'post_type_link', function($post_link, $id = 0){ | |
$post = get_post($id); | |
if ( is_object( $post ) ){ | |
$terms = wp_get_object_terms( $post->ID, 'offer_category' ); | |
if( $terms ){ | |
return str_replace( '%offer_category%' , $terms[0]->slug , $post_link ); | |
} | |
} | |
return $post_link; | |
}, 1, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment