1

I have created two custom post types (CPT) say books and reviews. Now how can i auto generated a reviews page for a specific book title??.

What i have done so far i made a review page (page-reviews.php) which displays the reviews based on a book's $id. In CPT "reviews" there is a dropdown menu with id's corresponding the book title.

I thought of something like mydomain.com/books/{title-book}/reviews

But how can i auto generate this url path to be recognized and how do i get the book's $id in reviews (page-reviews.php)

should i alter the 'hierarchical' => true, 'rewrite' => array( 'slug' => 'reviews' ),

Regards,

  • I would suggest that where you have a review of a book, the book post be the parent post of that review. How you would set up the URLs and archives however is up to whoever answers the question – Tom J Nowell Sep 12 '14 at 16:33
  • @TomJNowell tx, i am trying 'rewrite' => array( 'slug' => 'books/%postname%/reviews' ), which looks like what i want but i get a 404 – alex Sep 12 '14 at 16:51
  • You won't be able to do this inside the register_post_type call, that URL is for the location of the archive and review posts, not an archive of all review posts with a parent or link to another post of another type also in the URL. You will need custom rewrite rules and archives. – Tom J Nowell Sep 12 '14 at 18:03

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.