I need to re-write a current WP website and I think Custom post types are required, combined with Meta Box.

The basic layout is

Author (custom) Books (custom) Photos (custom)

All 3 custom post are individual but also "linked" in some way. An Author, will have written 2 Books and taken 10 photos

The same goes for when browsing for Books, I need to link the author, and then photos of this author.

How do I recreate a metaBox in each custom post to allow the Multi selection of other post. To clarify, when adding an Author, I need the ability to link Books and Photos to it (using their own types).

I hope it's "kind" of clear.

Will appreciate some help...


1 Answer 1


the old way

when i say "the old way" i mean my old way of doing this ,like i answered Need Help Finding a Wordpress E-Commerce Plugin That Utilises Custom Post Types before about creating relations between custom post types that i used custom fields for that meaning:

  • Author will have two custom fields (book_ids[], photo_ids[])
  • Books will have two custom fields (author_ids[], photo_ids[])
  • Photos will have two custom fields (book_ids[], author_ids[])

so this makes the query very easy like this:

//lets say you are need to get all books of an author

$q= array( 
    'meta_key' =>'author_ids', 
    'meta_compare' => '=' 
    'meta_value' => $author_id,

and as for the meta boxes lets say for the authors edit page you can create a multi select dropdown of the books and save the ids, and the save for photos.

Different approach

I'm currently working on a site that need relations like so but instead of creating CPT (custom post type) for all 3 , in your case, i create the photos,books as custom post types and authors and custom taxonomy with extra fields added to them witch makes it easier to connect between authors to photos and book, and all i have left is to create relations between photos and books by custom fields like before, so basically what I'm doing is using custom taxonomy as a custom post type.

Hope this makes sense (at least some of it). this way you can connect

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.