This is what I have:
- Custom Post type "Books" with Taxononies/Categories "Genre" and "Author"
- Another Custom Post Type "Authors" which have all author pictures and bios.
This is what I want to do:
- On the single "Book" page, have a sidebar with the books "Author" picture and bio.
I know how to get the "Author" Taxonomy of a "Book" post, but the information I need is from the "Author" Custom Post Type with the same name. The only thing i can think of is that the slug for both would be the same (i.e. if the books author was "John Smith", the taxonomy would be "john-smith" and the post that I need to query from my "Authors" Custom Post Type would also be "john-smith"). I just don't know how to go about getting it or if there is another way of doing it.
I think it should be something like this:
$bookauthor = wp_get_post_terms($post->ID, 'author', array("fields" => "slug"));
$custom_query = new WP_Query(array(
'post_type' => 'authors',
'name' => $bookauthor
or this:
$bookauthor = wp_get_post_terms($post->ID, 'author');
$bookauthorslug = $bookauthor[0]->slug;
$custom_query = new WP_Query(array(
'post_type' => 'author',
'name' => $bookauthorslug
But neither works.