Custom Post Type Archives

Enables custom post type archives that will support both paging and feeds. All fully customizable.

Author:Rolands Atvars (profile at wordpress.org)
WordPress version required:3.0
WordPress version tested:3.2.1
Plugin version:1.5.1
Added to WordPress repository:26-08-2010
Last updated:08-08-2011
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:100
Rated by:1
Plugin URI:http://ratvars.com/custom-post-type-archives
Total downloads:22 190
Active installs:400+
plugin download
Click to start download

Since version 3.1 WordPress has it's own implementation of custom post type archives so you can create them without this plugin - visit this page for more info -> http://codex.wordpress.org/Post_Types. Nevertheless I do believe that this plugin is more flexible and you can still use it and it will still work as expected.

This plugin will enable custom post type archives (also yearly, monthly and daily) together with feeds, customizable titles and paging.

These archives will work the same way as the category or tag archives work when you go to, for example, http://example.com/category/example.

WordPress 3.0 new custom post type feature is awesome. The only problem is - it lacks archive functionality for these post types so you can't easely assign one URL to just list your 'photo' post type posts. You also won't be able to get feeds just from this post type. This plugin adds this functionality to WordPress so that you can fully enjoy custom post types. It will also let you to create seperate templates for your post type archives which wasn't possible before. You will be able to use the same things you are familiar with if you are a theme developer as well as you will be able to enjoy this feature if you are not a developer but just want to enable this feature for your blog.

With this plugin you will be able to specify:

  • URL base for custom post types. Assuming you have a post type named 'photo', you can list all your post types in URL http://example.com/photo or http://example.com/post-type/photo - whatever you like by simply filling one field.
  • Whether to use the custom post type rewrite slug or custom post type name as URL parameter after 'URL base'. It defaults to true, because that's the way it should work, but it might be more efficient to disable this option. For more information please read the FAQ. Also if this option is enabled then you will be able to specify a custom rewrite slug for each enabled custom post type archive.
  • Title for post type archives. You can use {POST_TYPE_NAME} and {POST_TYPE_SINGULAR_NAME} variables into this option. {POST_TYPE_NAME} will be replaces with current post types name and {POST_TYPE_SINGULAR_NAME} will be replaces with current post types singular name. So if you are in post type 'photo' and this option is set to 'Post Type "{POST_TYPE_SINGULAR_NAME}"' then the title will say 'Post Type "Photos"'. You can also use {SEP}, {SEP_LEFT_SPACE}, {SEP_RIGHT_SPACE}, {SEP_SPACED}. These will be replaced with seperator specified in wp_title function. Spaced ones will have the space on defined side. {SEP_LEFT_SPACE} will have space in left side and vice verca. {SEP_SPACED} will have spaced on both sides. I had to do this in this way, because WordPress trims variables before saving. If left blank (this option), plugin won't change the title. You can also specify a custom title for each enabled custom post type archive.
  • What template file to use for rendering a custom post type. You can use either one template for all post types or just type 'post-type-{POST_TYPE}.php' and for post type 'photo' plugin will try to include 'post-type-photo.php' to render the custom post type.
  • What template file to load if above template file is not found. So it's easy to use index.php for all post types except 'photo' for example.
  • Whether to add a feed link for custom post type archive. Will work the same way as any other feed links, for example in category index pages where your visitors can subscribe to your site updates. Plugin will automatically insert the feed link if 'automatic-feed-links' is enabled for your theme. If that's true then plugin won't show this option in plugin settings.
  • Post types that gets archives. Just tick the checkboxes next to those post types you want to see archives. Easy as that.

Note that if you update URL base field, disable/enable post type rewrite tag usage or enable/disable some post type archives, then you will have to visit 'Permalinks' section under 'Settings' to flush old permalinks and enable the changes.

Also a good thing for theme developers - you have four new functions to use:

  • pta_is_post_type_archive - this function will work similary as is_category or is_single and so on. It will return true if this page is a custom post type archive or false if it isn't. You can also specify an optional argument with post type name and then function will return boolean to say whether you're in post type archive for that post type or not. Simple and useful!
  • get_the_post_type_permalink - this function will return a link to custom post type archive for current post in the WordPress loop. Or you can specify a post type slug or post ID or post object as an argument if you are not in a loop. In this way you can always link to custom post type archives wherever you are.
  • the_post_type_permalink - uses get_the_post_type_permalink to echo the link rather than return it.
  • wp_get_post_type_archives - will work the same way as 'wp_get_archives' function that allows you to get yearly, monthly, daily (and so on) archives for custom post types.

If you have any issues at all, please try these steps that hopefully will help you:

  • check out the Faq section to search for an answer for your question
  • visit plugins homepage (http://ratvars.com/custom-post-type-archives) for more information (you can also leave a comment there)
  • create a new forum topic in here about the issue you're having

I will try to help you as good as I can.


Screenshots
FAQ
ChangeLog