0

I am building an issue based wordpress magazine and am running into a few issues with custom post types and taxonomies.

I created a taxonomy called "Issues" so that any custom post type could be attached to a specific issue. I also create a custom post type called "Covers" which has the main cover art and issue information on it. The cover will be the main hub for each issue, providing access to all posts linked to the specific issue in the taxonomy.

My question is, how can I automatically generate a list of links to all the posts of an issue on the Covers post? Could I create a custom template for the Covers post type and include a query to grab all posts of any post types (besides the cover) with the same issue set?

Would there be a better/easier way of doing this? I'm just trying to avoid having to manually generate the index of each issue.

1
  • I would use a custom taxonomy for issue instead of post type. You just create more work with a custom post type in this scenario. I suppose if you really needed meta data associated with the issue, I might use a post type... But you should be able to do a WP_Query for the posts in specific post types that are associated with the issue or cover through a meta_query (or taxonomy). codex.wordpress.org/Class_Reference/…
    – Jake
    Commented Jul 4, 2013 at 18:00

1 Answer 1

0

What makes the most sense for you to do is not to try to make covers themselves specifically show all your articles, but to make the archive page for your "Issues" taxonomy include both the cover and the articles. This is better both conceptually and practically.

To to do it, I'll assume your issues taxonomy has the slug "issues". Then, what you should do is create in your theme a file called taxonomy-issues.php (I'd start by just duplicating your existing archives.php and renaming it), this will then be used by WordPress as the default view for all issues taxonomy archives. (If you're curious, the source of that wizardry is the WordPress Template Hierarchy.) So that if a user goes to //yoursite.com/issues/1, they'll see a page generated by taxonomies-issues.php.

With that set up you can then customize your taxonomy-issues template to include pulling in other post types like the cover. The most obvious thing to do would be to have your cover posts use the same slug as your issue, so that (given my example) your first cover would just have a slug of 1, or 1-cover, or some other obvious format so you can easy pull it into that template programmatically by using something like (or literally) get_page_by_path().

2
  • I understand the concepts here (even if I don't know how to actually make it happen quite yet), the only issue is that I am using a plugin to make the current Cover display on the main page, so I assumed I would need the issue index in that post. Is it possible to display the newest entry in a taxonomy as the main page?
    – Alex Getty
    Commented Jul 4, 2013 at 20:52
  • Without knowing anything about that plugin (from the WordPress repository, someone wrote if for you, etc), I'd just change the link you're wrapping around the cover to point to the Issue the cover is for rather than the cover page post itself. Commented Jul 4, 2013 at 22:09

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.