Costum post type with costum (sub)taxonomy

When asigning a post to a taxonomy, if you assign it to both a top-level and child term, the top-level will be used in the permalink. If you only select the child, I believe the parent term will be displayed as well. I agree, that this is not ideal and you may be able to work something out with wp_rewrite() but there’s an easier way to get the parent term:

On the post page you’ll need wp_get_post_terms(). This will return an array of terms associated with the post. If you only want the top-level term for the post, pass parent = 0 in the args array as I’ve done below.

$args = array( 'parent' => 0 );
$terms = wp_get_post_terms( $post->ID, 'taxonomy_name', $args );
echo '<pre>' . print_r( $terms, 1 ) . '</pre>'; // raw output

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)