Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?

I am building a theme in which I have a post type, which will have an archive in a grid layout. You’re probably thinking, “Just use the CPT archive!” Well, there are some cons to that method that I’d like to avoid, which I’ve detailed below.

This archive page needs to be as easy-to-use for the end user as possible, and ideally highly configurable. I am considering these three different ways to provide a CPT archive, and I am wondering which method will be the easiest to use for the person setting up the theme.

I have the following criteria:

  • The user needs to be able to add their own WYSIWYG content (text, images, etc.) above the post type archive, without editing template files and writing HTML manually.
  • Adding content below the archive would be a plus, although not necessarily a hard requirement.
  • The user needs to be able to easily add the post type archive page to their nav menu, and have it display the as the selected menu item when viewing the archive.
  • The user needs to be able to easily change several archive grid display settings.

I am wondering which method is best, given my requirements, but also whether I have overlooked any pros or cons to any of these methods that I should consider. Remember, I am trying to make this as easy for the user as possible.

1) Built-in CPT archive

Pros:

  • Most “WordPress-y” way to do it
  • Page is created automatically by WordPress if the has_archive parameter is true in the post type registration
  • I can easily retrieve the URL of the CPT archive for use elsewhere on the site.

Cons:

  • The only way to add text above or below the archive without manually editing the template file, would be to add a textarea in the customizer or theme options panel. This is a negative because it would most likely not be the full WordPress WYSIWYG editor experience, for instance the media library could not be browsed when inserting images.
  • Does not appear in the nav menus, needs to be added as a custom link. My users will likely not be able to figure that out on their own.
  • Does not trigger the “current menu item” css class in the menus when the CPT archive page is viewed on the frontend.
  • The user cannot change the page title (unless a facility for doing so is provided in the theme options).
  • The user cannot set a featured image for the page.
  • The user cannot change the URL of the archive page.

2) Page Template

Pros:

  • User can use the page content WYSIWYG editor to create their page content.
  • Archive settings can be changed in a meta box
  • Easy to add to the menu

Cons:

  • Not the most “WordPress-y” way to do this
  • Requires an extra step for the user to select the page template
  • No place to edit WYSIWYG content for below the archive
  • I cannot automatically retrieve the URL of the archive page elsewhere on the site.

3) Archive Shortcode

Pros:

  • Can add WYSIWYG content both above and below the archive grid
  • Can specify archive settings via shortcode parameters

Cons:

  • The least “WordPress-y” way to do this
  • Using shortcodes and shortcode parameters are not as easy to use as point-and-click settings in a meta box.
  • I cannot automatically retrieve the URL of the archive page elsewhere on the site.

Any advice, or pros/cons that I’ve overlooked would be welcome.

2 Answers
2

I’m posting my comment to @MarkKaplun as part of my answer.

My point is this, every end user experience a certain thing in a certain way based on his/her own knowledge, experience, usability and personal preference. There can never be a wrong or right answer here. Option one might suite you best, option two might suite me better. I like the way the OP has set out all pro’s and con’s, and his points are valid. I think we all miss the real question here. What type of market are you targeting here. Will this be distributed to people with a lot of knowledge or novices in WordPress.

To extend my comment into a full answer, I would like to add the following:

  • Whatever option you are going to implement, you should include a well documented step-by-step instructions manual with your theme.

  • Always think like a novice, someone that have no to very little experience with WordPress and php when developing a theme or plugin for public distribution.

  • Choose a target market and develop your theme according to that specific market. Remember, you can never please everybody.

  • On the point of the URL, will you really be using the URL of your archive page somewhere else in your theme

  • Write a custom walker to include archive pages automatically when a new custom post type is created. No need to add links manually

  • Make use of custom widget areas and custom meta boxes to include extra information from the back end. I personally think this is the most dynamic way of doing it

  • Not the best option, but make use of a custom post type to add an additional post area in your archive page. This way, you can make use of the WYSIWYG editor. You can add that content then via a custom query or a custom widget.

I think there are still a lot of point I did not cover, but this is most probably the most important

EDIT 1

Just for extra info on page templates. In stead of creating a page template for every post type, you can use a dynamic page which you can use. Please refer to this post I recently did. It might be a bit overboard, but this template can come in handy

Leave a Comment