Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function recipes_post_link( $post_link, $id = 0 ){
- $post = get_post( $id );
- if ( is_object( $post ) ){
- //$terms = wp_get_object_terms( $post->ID, 'recipe-category' );
- $terms = get_the_terms( $post->ID, 'recipe-category' );
- //echo '<pre>' . var_dump($terms) . '</pre>';
- foreach($terms as $term) {
- if( $term->slug == 'ristorante' || $term->slug == 'utenti'){
- //var_dump($post_link);
- //var_dump($term->slug);
- return str_replace( site_url()."/ricetta" , site_url()."/ricetta/".$term->slug , $post_link );
- }
- }
- }
- return $post_link;
- }
- add_filter( 'post_type_link', 'recipes_post_link', 1, 3 );
- function custom_rewrite_basic() {
- add_rewrite_rule('^ricetta/(.+)/(.+)', 'index.php?recipe=$matches[2]', 'top');
- }
- add_action('init', 'custom_rewrite_basic');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement