Plugin Directory

Test out the new Plugin Directory and let us know what you think.
!This plugin hasn’t 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.

Custom Post Type Archives

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

Why my URLs doesn't change when I change the 'URL base' option or my post types still doesn't have archives when I add them to 'Enabled Custom Post Type Archives' option?

You should go to 'Permalinks' submenu under 'Settings' menu in WordPress admin backend after you update 'URL base' or 'Enabled Custom Post Type Archives' options. This will force WordPress to flush the old rewrite rules and re-generate the new ones that will have the stuff plugin needs in them.

What should I put in 'URL base' option?

The prefix for URLs that will lead to your post type archives. If you want to access your post types from URL 'http://example.com/{POST_TYPE}' then leave this option blank. If you want to have an URL 'http://example.com/post-type/{POST_TYPE}' then you would put 'post-type' as this options value. And if you want 'http://example.com/some/long/link/to/post/type/{POST_TYPE}' then you would put 'some/long/link/to/post/type' as options value.

What's the deal with 'Use Rewrite Slug' option?

This might be a bit hard to understand. If you don't know what it is, then leaving it enabled, probably, is the best option. By default the rewrite slug will be the same as post type name, but you can change it if you like. Please look at these examples:

register_post_type('photo', array(
    /* other options */
)); // will have a rewrite slug 'photo'

register_post_type('photo', array(
    /* other options */
    'rewrite' => array('slug' => 'awesome-photo')
)); // will have a rewrite slug 'awesome-photo'

If you never specify a custom rewrite slug, then I would suggest disabling this option because it will work just fine, because the post type name will be the same as the rewrite slug. Although, if you specify custom rewrite slugs, then enabling this option is what you want, otherwise the URLs will have the post type name in them not post type rewrite slug. I made this choise, because I think (note the 'I think' - I havent tested it...yet), that disabling this option will make the code a bit faster.

What should I put in 'Title' option?

You put the title you want to appear in post type archive in here. You can use several variables in this option:

  • {POST_TYPE_NAME} - replaces with current post type name (in plural)
  • {POST_TYPE_SINGULAR_NAME} - replaces with current post type name (singular)
  • {SEP} - replaces with seperator (which is specified in wp_title function)
  • {SEP_LEFT_SPACE} - replaces with seperator prefixed with space
  • {SEP_RIGHT_SPACE} - replaces with seperator suffixed with space
  • {SEP_SPACED} - replaces with seperator wrapped in spaces

I have so many space variables because WordPress trims variables before saving. Anyway - if you have a post type with name 'Photo', a seperator '»' and 'Title' options value '{POST_TYPE_NAME} {SEP}', then title on 'Photo' post type archive would be 'Photos »'.

If you leave this option blank, then title won't be changed (it will probably be blank).

It's also worth noting that the same variables will be available for the custom - per custom post type - 'Title' options as well. If they are left blank then it will fall back to global 'Title' option.

What should I put in 'Template Pattern' option?

The template name that will be used to render post type archives. You can use a {POST_TYPE} variable in this name and that will be replaced with current post type. So if this option has a value 'post-type-{POST_TYPE}.php' and you are in 'photo' post type archive, then 'post-type-post.php' template will be used. Templates should live in the root of your theme directory. If you leave this field blank then it will default to '{POST_TYPE}.php'.

What should I put in 'Fallback Template' option?

Name of the template that will be used if the template that's stored in 'Template Pattern' option won't exist. So if you have 'Template Pattern' option value of '{POST_TYPE}.php', 'Fallback Template' option value of 'fallback.php' and you are in a post type archive for post type 'photo', but 'photo.php' doesn't exist then 'fallback.php' will be used. Template should live in the root of your theme directory. If you leave this field blank, then it defaults to 'index.php'.

Why isn't the 'Enable feed links' option showing up in plugin settings?

That's because the 'automatic-feed-links' support is enabled for your theme. Don't worry - the feed links will be included automatically!

Why can't I see the 'Rewrite Slug' option for each enabled custom post type archive?

You can only see this option if 'Use Rewrite Slug' option is enabled.

How can I disable feed link adding if 'automatic-feed-links' support is enabled for my theme?

Sadly you can't do it from backend. But! You can do it using the 'pta_add_feed_link' filter! Just return false in it and thats it! Here's an example (put this in themes functions.php file):

function disable_pta_feed_links($add_feed_links) {
    return false;
add_filter('pta_add_feed_link', 'disable_pta_feed_links');

Where do I find the feeds for post type archives?

Just put '/feed/' at the end of your post type archive URL. That's how WordPress will know that you want an RSS feed of that. (it will also support all the other feed types as well, like atom and rdf)

How do I use the get_the_post_type_permalink and the_post_type_permalink functions?

get_the_post_type_permalink function will return the permalink where the_post_type_permalink will echo the link.

You can pass an optional argument for these functions:

  • If you pass nothing or false, then function will assume that it's called from WordPress loop and will get the post type link for current post in the loop.
  • If you pass an integer (cast it to integer using '(int) $id' just to be safe) then functions will assume that it's an post ID and will get post type link from post with this ID.
  • If you pass an object then functions will assume that it's an post object and will get the post type link from that post object.
  • Also you can pass a string that has to be a post type slug. Functions will use this string to create a link.

If at the end functions can't get the post type slug then will return/echo an empty string.

How do I use the wp_get_post_type_archives function?

The functon takes two arguments:

  • Post type rewrite slug to get archives from or 'all' to get archives for all the post types
  • Array of options. It uses the same options (because it uses that function) as the 'wp_get_archives' function so please read that documentation.

Function will do the same thing as the wp_get_archives function (it even uses the same function to get the data). I had to create a wrapper for that function because WordPress lacked hooks to let me fix the URLs that came out. Basically it it the same function with additional 'post_type' argument so please read the wp_get_archives documentation.

P.S. It might not work properly with 'weekly' archives.

Requires: 3.0 or higher
Compatible up to: 3.2.1
Last Updated: 5 years ago
Active Installs: 1,000+


5 out of 5 stars


Got something to say? Need help?


Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1 100,1,1 100,1,1 100,2,2 100,1,1 100,1,1
0,2,0 100,2,2