Finally, found a solution mix:
The CPT has to have:
'has_archive' => 'library', // Fixes the archive URL.
'rewrite' => array(
'slug' => 'library/%library-category%',
'with_front' => false,
)
Taxonomy should be as following:
'rewrite' => array(
'slug' => 'library',
'with_front' => false,
),
And than you need to rewrite the links:
/**
* Custom rewrite rules for URL
*
* @param string $post_link Post link url.
* @param integer $id Post ID.
* @return string
*/
function getmanta_technologies_post_link( $post_link, $id = 0 ) {
$post = get_post( $id );
if ( is_object( $post ) ) {
$terms_lc = wp_get_object_terms( $post->ID, 'library-category' );
if ( $terms_lc ) {
return str_replace( '%library-category%', $terms_lc[0]->slug, $post_link );
}
}
return $post_link;
}
add_filter( 'post_type_link', 'getmanta_technologies_post_link', 1, 3 );