1

I have three Custom Post Types: Book, Volume and Chapter where one Book can contain many Volumes and one Volume can contain many Chapters.

I want to do something like this:

  1. The user access "Books" enter image description here

  2. The user select a book for editing and, inside that page, on the meta box, he can add/edit just the volumes relating to that book enter image description here

  3. The user select a volume for editing and, inside that page, on the meta box, he can add/edit just the chapters relating to that volume enter image description here

  4. The user finally select a chapter to edit enter image description here

I initially thought of putting an iframe inside the meta box area on the post types using the src attribute as edit.php?post_type=post_type with some filters on its query string, to list just the post type related to the respective page.

What would be best in that situation?

Is that a pattern on WordPress to work with situations like that, where Custom Post Types needs to be Custom Fields of another Custom Post Type, i.e. one to many entity relationship?

1

Just using hierarchical post types is completely valid. You can do nearly everything with that and probably won't need to go beyond that.

If you really need n/n relationships (which I doubt from your description), take a look at the Posts2Posts plugin.

  • Hi @kaiser, thanks for the answer! I consider the hierarchical posts great for small institucional and regular websites, but imagine a website with 100 books, with 3 volumes each, and 15 chapters each volume published as different pages. There will be a time where it would be too difficult to recognize and select the correct post, between hundreds and thousands existing, from the select box, to correctly relate the posts with each other. What I'm looking is a way to do as I'm describing above and make the process easier and logical so anyone could manage the site. – João Paulin Oct 27 '13 at 4:15
  • Then look into the plugin. – kaiser Oct 27 '13 at 4:17
0

why don't you use Book as Custom post type and Volume and Chapter as Custom Taxonomy?

or

If you want to use only Custom Post Type. Please use [Advanced Custom Fields][1]

[1]: http://www.advancedcustomfields.com/ plugin.

With that plugin you can do many things. and it has very good documentation.

  • Hi Kaung Ko, thanks for the answer! I don't think using Volumes and Chapters as Taxonomies would be a good idea, because they are not just classification labels, they would have to have a title and a content as well. I didn't put the Content Text Area on the screenshot for viewing purposes, but they will have. So, I cannot use them as taxonomies. I think it would have to be something like I've described: an iframe with edit.php?post_type=post_type as its src listing only associated objects. – João Paulin Oct 28 '13 at 13:23
  • Hi! João Paulin. thx for the info. you can add title and description to your terms. But you are right, you can't use taxonomy as you want to relate all of them together. As I recommend before please use that Advanced Custom Field plugin. There you can easily relate posts and custom post types and even it have repeater fields. So, you can relate Book with volumes and Volumes with chapters. Hope my advice would help you. Good luck with your project. – Kaung Ko Oct 28 '13 at 22:26
0

I agree with @Kaung Ko's answer - I just finished a project using Custom Post Type and Custom Taxonomies. Very similar to yours but for Wine Reviews. Also used the Advanced Custom Fields plugin for further customization.

@João Paulin - do you have a plugin installed for that custom Admin style (black left column) in the screeshots? That looks much better than native Wordpress.

  • Hi codeview, thanks for the answer! Yes, this is a new Admin style that is being discussed to be native to WordPress starting on the 3.8 version, but, for now, you can have it installing a plugin called "MP6" http://wordpress.org/plugins/mp6/. Just install and activate. – João Paulin Oct 28 '13 at 13:07
  • Hmmm... very interesting. Thanks for sharing "the secret", haha. – codeview Oct 28 '13 at 16:54

Your Answer

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

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