Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am looking to create two custom post types, one of which is a child of the other. Let's call them Authors and Books for simplicity.

Authors should be a top level URL and the landing page for them should show a list of all their authored books. So you'd have something like:

http://mysite.com/Shakespeare/ http://mysite.com/Shakespeare/Macbeth http://mysite.com/Shakespeare/Othello

How do I create something like this in Wordpress? I am fine if it requires custom coding, just not sure how to express the relationship of post types to Wordpress.

share|improve this question
add comment

2 Answers

If it's a one-to-many relationship (an author can have multiple books, but a book can't have multiple authors), you can use the post_parent field in the posts table.

If it's a many-to-many relationship, you can use my Posts 2 Posts plugin.

To generate those urls, you can use the 'post_type_link' filter.

Finally, to match those URLs later, you can fall back to the page rewrite rule and manually parse the components (use the 'parse_request' action).

share|improve this answer
add comment

To me the most logical would be to have a "Book" custom post type, and then all the attributes of the books (Author, Collection, Genre, etc.) would be custom taxonomies.

Then for your URLs you could use some custom URL rewrite method to get what you want.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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