Answers for "add custom taxonomy into permalinks post_type_link"

CSS
0

add custom taxonomy into permalinks post_type_link

'rewrite' => array('slug' => 'courses/%course%')
Posted by: Guest on June-03-2021
0

add custom taxonomy into permalinks post_type_link

function wpa_course_post_link( $post_link, $id = 0 ){
    $post = get_post($id);  
    if ( is_object( $post ) ){
        $terms = wp_get_object_terms( $post->ID, 'course' );
        if( $terms ){
            return str_replace( '%course%' , $terms[0]->slug , $post_link );
        }
    }
    return $post_link;  
}
add_filter( 'post_type_link', 'wpa_course_post_link', 1, 3 );
Posted by: Guest on June-03-2021

Code answers related to "add custom taxonomy into permalinks post_type_link"

Browse Popular Code Answers by Language