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.

  • What part(s) do you not know how to get? – s_ha_dum Oct 16 '13 at 18:24
  • Please edit your question to include your current code, and explain what's not working as expected, or is happening unexpectedly. – Chip Bennett Oct 16 '13 at 18:42
  • There is no code yet. I need to query the author custom post type that has the same name as the book's taxonomy. Suggestions are welcome. – Troy Templeman Oct 16 '13 at 19:08
  • From what it sounds like you're trying to do, you might take a look at the Posts-to-Posts plugin (wordpress.org/plugins/posts-to-posts), and skip the taxonomy completely. – Jen Oct 16 '13 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.