I have the following code that gets the slug of the taxonomy "author" from a custom post type "books" and gets the post from another custom post type "authors" that has the same slug.


global $post;
$bookauthor = wp_get_post_terms( $post->ID, 'author' );
$slug = array_shift( $bookauthor );
$custom_query = new WP_Query( array( 'post_type' => 'authors','name' => $slug->slug ) );

if($custom_query->have_posts()) : 
while($custom_query->have_posts()) : 


Now I need to get the slug of a child taxonomy of "author" called "new-author" but don't know how to modify the code.

Suggestions welcome!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.