- Rolands Atvars -

Page August 23, 2010

Custom Post Type Archives

WordPress’s custom post types are a pretty big deal in the WordPress 3.0. If you don’t know what they are, then you should, probably, read these articles:

because I won’t explain custom post types here.

Sadly these custom post types lack archive functionality. It’s pretty hard to create a dedicated (like category or tag archive) area for a custom post type. This is where this plugin comes to help.

By enabling this plugin you will be able to create custom post type archives by:

  • specifying and URL sample for custom post archive
  • specifying which template to include for which custom post type
  • specifying what title do you want to see in these archives
  • choosing whether you want to see feed links in head
  • select custom post types to whom enable archive feature

The simplest scenario ever is to:

  1. enable plugin
  2. go to plugins settings and tick post types to whom you want to enable archives
  3. go to permalinks page under WordPress settings to flush existing permalinks

and thats it – your custom post type archives will be accessible from URL like ‘http://example-blog.com/post-type/{POST_TYPE}‘ where {POST_TYPE} is your custom post types slug. index.php will be used as a template in this case.

These custom post type archives will have ‘post-type-archive’ and ‘post-type-{POST_TYPE}-archive’ body classes.

And want to know the awesome part? Paging, feeds and daily/monthly/yearly archives will work for these archives the same way as for other archives! Isn’t that great?

Also you will get two helper functions:

  • pta_is_post_type_archive – which will tell you whether you are in an custom post type archive, similar as to is_home or is_category and so on…Also you can specify an optional argument of post type name. If you do that then function will tell you whether you’re in a post type archive with that name.
  • the_post_type_permalink – which will output the URL to custom post types archive. This can be used in WordPress loop or you can specify an optional parameter with post types slug.
  • wp_get_post_type_archives – this function works the same way as the wp_get_archives function does so please read that functions documentation for detailed info. The only difference is that the first argument is custom post type rewrite slug you want to see date archived. Second argument is the normal options as in ‘wp_get_archives’ function (this function uses wp_get_archives function to get data so there shouldn’t be no confusion). The only reason why I had to make this wrapper function is that I had to fix the URLs that wp_get_archives returned and I couldn’t do that using hooks so that’s why there is this function.

The plugin is now available from WordPress Plugin Directory. Here is the link: http://wordpress.org/extend/plugins/custom-post-type-archives/. I suggest you download the plugin from there so I won’t even put a download link on this page. I suspect that that page will be the first one to update if I release a new plugin version. And I will, probably, write some blog post about a serious release. So keep your eyes open. This will be the last place that gets my updates, but I will still keep it up to date.

To know more about changes in new releases – this is a list of all the articles I make for every new release:

And also you can look at the actual changelog.

Options explained

Options Page

You have 7 options.

URL Base

This is the URL base for the custom post type archives. If left as blank then post type archives will be accessible from URL like http://example-blog.com/{POST_TYPE}. If URL Base is set as ‘post-type’ for example, then the post type archives will be accessible from URL like http://example-blog.com/post-type/{POST_TYPE}’.

Note that you will have to go to ‘Permalinks’ under ‘Settings’ to flush the old permalinks when you update this option. It’s just safer this way than for me to code that in automatically.

Use Rewrite Slug

This is a bit tricky option. As you may know – it is possible to specify a custom rewrite slug for custom post types. If it’s not set then the custom post type name will be used as rewrite slug. Please look at these examples:

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

Now – why would I need to include this option if enabling this option is clearly the accurate way to go (according to WordPress). The thing is – it’s a bit faster to disable this option (faster meaning – it will process more quickly), because it will create less custom rewrite rules. The difference won’t be big, possibly nanoseconds (if any) but still.

Since most of the people won’t specify a custom rewrite tag I’ve chosen to add this ability to disable this option to make it more efficient. Also it defaults to enabled so that means that when you first install this plugin, then it will work as WordPress expects this to work.

For the most cases I would probably suggest you enable this option, but if you really know (like me on this blog site @ ratvars.com) that you won’t use custom rewrite slugs then disabling might be a better choice. Anyway – changing this is as easy as checking/unchecking the checkbox, saving and visiting permalinks.

Note that you will have to visit ‘Permalinks’ under ‘Settings’ if you change this option for the changes to take  proper effect!

Title

Use this option to specify what title do you want to see in post type archive pages. This option supports several variables:

  • {POST_TYPE_NAME} – plugin will replace this with current custom post types name (plural)
  • {POST_TYPE_SINGULAR_NAME} – plugin will replace this with current custom post types singular name (singular)
  • {SEP} – seperator as specified in wp_title function
  • {SEP_LEFT_SPACE} – seperator prefixed with space
  • {SEP_RIGHT_SPACE} – seperator suffixed with space
  • {SEP_SPACED} – seperator wrapped in spaces

In this way it is easy to create a title like ‘Welcome to my “Photo” post type’ by just setting this option to ‘Welcome to my “{POST_TYPE_SINGULAR_NAME}” post type’.

If this option will be left as blank, then the title won’t be changed – in most cases that means that the title will be empty (unless you have a custom wp_title filter or some of your used plugins uses this filter).

Template Pattern

Specify this so that plugin knows what template to load for custom post type archives. You can use {POST_TYPE} variable inside this pattern that will be replaced with actual post type slug.

For example – if you have a post type with a slug ‘photo’ and this option is saved with value ‘post-type-{POST_TYPE}.php’ then this plugin will try to load ‘post-type-photo.php’ template to render out the post type archive.

Plugin uses locate_template function to find the template.

Fallback Template

If plugin can’t find post type archives template as saved in Template Pattern variable, then plugin will load this template to render the archive.

If we take the above example and we have saved this option with value ‘post-type-catcher.php’ and ‘post-type-photo.php’ doesn’t exist, then plugin will try to load ‘post-type-catcher.php’.

Note that if plugin doesn’t find this template as well, then it will load the default template that WordPress thought is correct. This could be either 404.php or index.php.

Plugin uses locate_template to find the template.

Enable feed links

This is a simple checkbox option that when checked, enables feed links and when unchecked – disables it. It will basically put feed link in the head of HTML. This link will lead to the custom post type feed. In this way your visitors will be able to subscribe to your post type content updates.

Note that this option is ‘automatic-feed-links’ theme support aware. If this theme support option is enabled then you won’t see this option in the plugins settings and feed links will be included automatically (without the need to use this ‘Enable feed links’ option – that’s why it’s not visible in this case).

If you want to disable feed links when ‘automatic-feed-links’ theme support is enabled, you need to use ‘pta_add_feed_link’ filter in where you just return false. See this example (which you can put into your themes functions.php file and it should work).

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

Enabled Custom Post Type Archives

For this option you just have to check the checkboxes to those custom post types to whom you want to enable archives.

Customisations per every enabled post type archive

You can also customise some values per every enabled custom post type archive. These values are:

  • Title
  • Rewrite Slug

With these you can set custom things for every post type archive. To know more please read v1.3 release article.

Donate

That’s about it. Feel free to ask me questions and add feature requests and bug notices. Also you can donate if you like :) Thanks!



Some say...

August 28, 2010 @ 01:40

OK, but how is this plugin different from Simple Custom Post Type Archives?

http://wordpress.org/extend/plugins/simple-custom-post-type-archives/

August 28, 2010 @ 11:59

Although ‘Simple Custom Post Type Archives’ is a good plugin that does many great things (some of them that this plugin can’t currently do), it doesn’t support any customisation from WordPress backend. (permalink structure, title, what templates to include and what post types will have archives).

Also you can easily link to these post type archives via the_post_type_permalink function.

September 09, 2010 @ 07:35

I have a problem with the default URL structure. My post type name is ‘shoe’, but the slug is ‘soccer-shoes’. I’d like to visit my archives based on the slug, so /soccer-shoes/. I tried {POST_TYPE_SLUG} as a template tag but that didn’t work. Any chance on getting that added to the plugin?

September 09, 2010 @ 12:15

Template pattern specifies what template to load for each post type. So if you want to include ‘soccer-shoes.php’ you would put ‘{POST_TYPE}.php’ into ‘Template Pattern’.

About URL structure. If you:
– leave the ‘URL Base’ field blank
– select the ‘Shoe’ custom post type for ‘Enabled Custom Post Type Archives’
– save the options
– visit Permalinks (under settings)
then your ‘Shoe’ post type should be accessible from the url -> ‘http://your-domain.com/soccer-shoes/'.

I hope that I understood your problem and this helped – if not, please correct me in things that I didn’t understand correctly.

Thanks.

September 09, 2010 @ 17:20

Rolands, thanks for your response. My template loads just fine. My problem is that my post type is ‘shoe’, not ‘soccer-shoes’. When I leave the URL Base field blank, I can access my archives from soccerreviews.com/shoe, not from soccerreviews.com/soccer-shoes.

September 09, 2010 @ 18:01

Oh – yes. Now I understand. Sorry about that.

Yes thats well spotted. I will create a new version (with rewrite slug support) as soon as possible.

Thanks again.

September 10, 2010 @ 16:39

Hi Rolands!

First of all, dozen of thanks for a great plugin, really a life saver. I have a one feature request though – can you make is_post_type_archive() function to accept parameter to check for exact post_type? i.e. is_post_type_archive(‘movie’). This will be very very useful in many situations.

Thanks again. Yuri.

September 10, 2010 @ 17:15

Hi Yuri,

yes – that sounds like a really good idea! I will put that into my next release (after 1.2.1).

If it helps (currently) you can use something like:
‘if(is_post_type_archive() and get_query_var(‘post_type’) == ‘movie’)’ to check if you’re in the correct post type :)

Hope this helps for the near future.

Thanks for the feature request!

September 10, 2010 @ 18:59

Rolands – Thanks for the quick turnaround and release of 1.2.1. The new slug feature works great.

I have a few other questions / feature requests.
- I am getting a colon ‘ : ‘ in front of my titles. How do I remove it?
- Can we set custom page titles for different post types? For example, I might want to have one page title be ‘Movie Listing’ and another one be ‘Actor Archive’. There currently isn’t a way to differentiate.

Thanks again!

September 10, 2010 @ 19:19

Thanks Derek. I’m happy that the new release works for you :)

About colon. I assume you mean the titles for custom post types? To help me debug this could you, please, tell me :
– what’s your ‘Title’ value for this plugin
– how to you use wp_title() function in your title (http://codex.wordpress.org/Function_Reference/wp_title)

About custom titles. Yes – I’ve though about custom customisation for separate post type archives. I think that that might come into future releases. Currently you could try using the ‘wp_title’ filter with priority over 10 to override my value. Anyway – I will try to add this feature as soon as possible.

Thanks for noting bugs and making requests – very appreciated!

September 11, 2010 @ 05:35

ran into some problems.
custom type: recipe, rewrite slug: food/recipe
url base empty, rewrite slug is checked
saved, went to save permalinks, still can’t access my archive.getting 404 error.

here is a single object of that custom post type: http://pacura.ru/food/recipe/sour-cream-cake/ so the archives are supposed to be here: http://pacura.ru/food/recipe/ using index.php as I haven’t created special templates yet.

Oh and btw. would there be a way to use the plural form instead of singular, I mean I like that it says food/recipe/name-of-recipe but when its an archive it should say: food/recipes/ :-)

September 11, 2010 @ 20:33

Hi,

I think, that it is some kind of bug when there is a slash in the slug. Haven’t had a chance to test it yet, but I will try to do it tomorrow and possibly commit a bugfix.

And I agree about the plural. :) That might come in future releases as well :)

Thanks for posting this and I’m sorry that you ran into problems, but like I said – I will try to fix it ASAP.

September 11, 2010 @ 23:13

Ovidiu,
at its current state custom post types unable to support custom permalink structures defined via rewrite slug. Here one of workarounds describing problem – http://wordpress.org/support/topic/fix-included-support-date-permalinks-with-custom-post-types

September 11, 2010 @ 23:54

@Yuri:
not the same type of problem. I know there is a custom permalink plugin for custom post types out there that lets me create permalinks for custom post types just like I do for normal posts but that is not what I am after here.
@Yuri + @Roland:
Remember the days when everything on our blogs had /blog/ in it to separate it from the main site?
I just want everything food related to contain the /food/ bit.
So I used the rewrite part for my custom post type to be “food/recipe” instead of just using the custom post type name which would have simply been “recipe”. Its all working and implemented.
I can’t seem to do this for my associated taxonomies to look like: “food/ingredients” for example as there the “/” seems not to be allowed but I am following that up in a different support topic in wp-land :-)

@Roland:
regarding the singular/plural, how about introducing some more variables we can use for generating the url base i.e. something like: [Plural Name:] to be able to use i.e. the plural name of the custom post type…

September 12, 2010 @ 18:05

ovidiu:

Hi again. I’ve tried to replicate your problem on my system, but I can’t seem to do that. Everything seems to be working.

Here is what I’ve tried:
– Plugin options:
– - Url Base: empty
– - Use rewrite slug: checked
– - Enabled custom post type archives: recipe is checked
– Post type options:
– - Name: ‘recipe’
– - rewrite:
– - – slug: ‘food/recipe’
– - public: true
– - publicly_queryable: true
– - exclude_from_search: false
– - query_var: true

Went to permalinks, created a new ‘recipe’ – could see it. Went to ‘recipe’ archive – could see that as well from URL: ‘http://domain.com/food/recipe/

Questions:
– what does the plugin say for the ‘recipe’s ‘URL’ and ‘Template’ (you can see that below the ‘recipe’ post type checkbox in plugin options)? Are they correct?
– do you use some other plugins (or your own functions) that does something with permalinks?

I hope that this will help me to replicate the bug you have.

And about custom fields – yes that’s what I thought as well :) I will probably add extra fields for every enabled post type archive to customise some values :)

September 12, 2010 @ 23:23

I don’t know what happened, it works now. no idea what I did (I admit I had activated and tested a couple of custom post types and taxes plugins over the last week trying to find the best one for me but I usually disable them after testing…)
it works fine right now. now I have to figure out how my theme handles templates and create one as the index.php isn’t good for me ’cause it shows all post types it doesn’t filter by type. check it out here: http://pacura.ru/food/recipe/
I currently have only one recipe, just laying the grounds right now, but when you access that archive it shows all post, no matter from which category or type they are…
But that is a different story I guess and not your plugin’s fault. msut be my theme: using a child theme built off hybrid

September 13, 2010 @ 00:27

oh and here is another problem, maybe you have an idea: it works currently see it in action at the url provided above but I can’t get rid of all other post types :-( I enabled the showing of custom post types and pages additionally to posts on my homepage like this:

`/*show pages and recipes on home page */
function my_get_posts( $query ) {

if ( ( is_home() && false == $query->query_vars['suppress_filters'] ) || is_feed() )
$query->set( ‘post_type’, array( ‘post’, ‘page’, ‘recipe’) );

return $query;
}`

is there a way to have custom post types on my home page and your plugin active? I asked the author of my parent theme and he says that even if the plugin provides rewrite rules to change the default structure, it’s still the home page to WP. There’s nothing built into WP to recognize it as anything else.
Meaning it seems I have to either remove showing custom post types on my home page or I can’t have your plugin creating archives for me…. do you see a way out?
Or is it as simple as creating a template for my archives that does not let wordpress slip in any other post types?

sorry I hope I am making sense its a bit hard to express all this :-)

September 13, 2010 @ 08:18

By default (on normal theme, not child at least) WordPress should only pull articles from given post type in post type archive pages, but since you have a child theme, then I’m not sure what happens :/

There is a hack in the plugin that tells WordPress that post type archives is not home, so is_home() should return false in custom post type archive.

Do you have any other $wp_query alterations on your site? Also – if you include index.php to show post type archives, then do you have query_posts() on top of it?

By default (if the $wp_query) isn’t modified, WordPress should only pull the posts from current post type archive, but if there are some changes to the $wp_query ‘post_type’ parameter, then anything is possible :(

First thing to try is changing your my_get_posts function to have something like:
‘(is_home() && false == $query->query_vars['suppress_filters'] && !is_post_type_archive()) || is_feed()’

if that still doesn’t work, then maybe looking for query_posts function could be an idea :)

I hope that this will help :)

September 13, 2010 @ 09:42

now that did the trick :-)
but I got the same problem as derek above. you said:

About colon. I assume you mean the titles for custom post types? To help me debug this could you, please, tell me :
– what’s your ‘Title’ value for this plugin
– how to you use wp_title() function in your title

what do you mean by title value? have a look at the link provided above to see what I mean.

wp_title is used like this: http://pastebin.com/vGSiETiC hehe, you asked for it ;-)

September 13, 2010 @ 16:41

Thank you!

I tried the “other” plugin first but it didn’t do what I needed. I’m using your plugin along with the Custom Post Type UI plugin. Between the two they’re doing exactly what I want.

My big gotcha: I missed the step about updating the Permalink settings, and I didn’t catch it until I printed the instructions. Oops.

How do I donate? Your work has saved me some tremendous headaches.

Now to go edit some template files…

September 13, 2010 @ 17:24

ovidiu:

‘Title’ value: this is the ‘Title’ options value for this plugin :) Between ‘Use rewrite slug’ and ‘Template pattern’ :)

Thats one huge wp_title filter :D although I meant the wp_title() function that’s in the header.php (usually) betweet the <title> tags. Basically I just need to know the $sep and $seplocation values :)

Anyway – it seems like this plugin has a bug in how it deals with title output :( I will try to find a way to fix it :)

Todd J. List:

Thanks for the good words :) Glad that this plugin helped you! I will add a donate link at the end of this page. Wanted to do it for a while but kept forgetting about it.

Thank you and good luck with template files :)

September 13, 2010 @ 19:56

Ok, the title I use: You are welcome to browse my recipe collection!

regarding the title function:

between my tags is this function: hybrid_document_title() that is why I looked it up in the parent theme’s library and pasted it into pastebin :-))))

September 13, 2010 @ 21:06

I’ve just commited a new plugin release. That should fix the title issue :) Please read the new documentation for ‘Title’ option to see the changes.

Hope that that will fix the issue.

September 13, 2010 @ 23:21

works great, many thanks to you.

September 14, 2010 @ 04:31

Thanks for the plugin update. It seems to be working great. I like the new Title options. Is there any chance that we will be able to define the title on a per custom post type basis? That way I could have titles something like:
‘Welcome to all of my Photos’ for a photo cpt
‘Have a look at my family’ for a person cpt

September 14, 2010 @ 15:06

Awesome – glad that it all works now!

The extra customisation will come on next release I would think. Probably, at the end of this week.

September 22, 2010 @ 14:36

Cool, but if I have for example a custom post type “news”, how can I access a MONTHLY archive for them, as I can with normal posts? Is it possible?

September 23, 2010 @ 20:25

Roland, lielisks plugin! Paldies par to. Strādā tieši kā vajadzīgs. + ja vēl attīstīsi, dabūsi alus kausu :)

September 29, 2010 @ 16:53

I have made a custom post, a “page” template that uses custom loop to show posts using this method:

// Custom loop to show projects
$loop = new WP_Query(array(‘post_type’ => ‘mr_project’));
while ($loop->have_posts()) : $loop->the_post();

It looked like an archive page? What is the difference between this method and actual archive.

Now that I’ve set up th plugin i lost all of the body classes except “logged-in”. Menu item is no longer highlighted?

October 07, 2010 @ 17:37

Sorry for the late response everyone – I was on holiday so didn’t have enough time to check in here :)

Erik:
That isn’t possible…yet, but that sounds like a thing that I might add to next version.

Thanks for comment.

jam:
Paldies! [Thanks] ^_^

Marko:
Theoretically there isn’t a big difference in your version and this plugin, but I think using plugin is way more cleaner than using page templates for that. It’s also more customisable I think.

Yes there is a bug with body classes – I will fix it in next release. Thanks for noticing.

October 13, 2010 @ 16:13

Hi Rolands! Thanks for the plug-in! It’s fantastic!

However, I have one case that I need to solve…

I have two different post types that use the same custom taxonomy. For example, two post types named ‘men’ and ‘women’, and a custom taxonomy called ‘sizes’ with terms such as ‘large’, medium’, and ‘small’.

Post type archives would look something like this:

http://www.mysite.com/men/
(base on http://www.mysite.com/?post_type=men)

Now I need to show an archive of ‘large sizes’ for the ‘men’ only…

This permalink:

http://www.mysite.com/sizes/large/
(www.mysite.com/?sizes=large)

… would show posts from both ‘men’ and ‘women’…

So I had to do this:

http://www.mysite.com/sizes/large/?post_type=men

… to show the ‘men’ only.

Now my question is… can your plugin change the above url to this:

http://www.mysite.com/men/sizes/large/

or maybe this:

http://www.mysite.com/men/sizes-large/

or probably this (which ever is possible):

http://www.mysite.com/men/large/

It would certainly make the URL looks a lot nicer.

Hope it’s not so much trouble.

Thanks again for the plugin!!

Cheers!!!

October 21, 2010 @ 18:00

Hi Giraldi and thanks for the comment.

About your problem – sadly this plugin currently can’t do anything with custom taxonomies that are attached to custom post types, but in some future releases I might add some functionality that would generate URLs for that, because it does sound like something that’s possible and useful.

Currently only thing that I could recommend is to add custom permalinks yourself. I might add a tutorial about that in near future if that might help.

Sorry that I can’t be of much help now.

Anyway – thanks again and good luck!

October 23, 2010 @ 04:51

Hi Rolands,

Thanks for putting together this code, very nice.

I have gone around and around with rolling my own, using other scripts etc., and landed on your code as the best permanent solution, particularly because of the additional template tags you coded. ;-)

I did alter it slightly just by adding in the flush rewrite rules on activate and deactivate, just because I do a lot of experimentation. Actually, while I’m here, I was curious to ask why you didn’t implement that in your code – is there some drawback that I’m unaware of?

Real reason for commenting to you, other than the above is that I’ve been running into an interesting issue/bug with the is_post_type_archive() tag that I thought you might be interested in checking out.

Occasionally, it doesn’t return any value for at all for post_type and all of my conditionals break. It seems to be primarily triggered by other conditionals, but, I haven’t had time to do any kind of debugging on it myself.

If I deactivate and reactivate, the flush rewrites I’ve added clear it up, although only until something else triggers it again.

The site I’m implementing it on isn’t live yet, but, if you were interested in seeing if it is in fact a bug in the coding of that template tag, feel free to hit me up on my email and I’ll give you access to debug it.

Thanks again for your work on this Rolands!

November 01, 2010 @ 16:35

Hi Angelia!

First of all – sorry about the late response :)

About the permalink flushing. The main reason was that it’s not always necessary to flush the rewrite rules (not all the options will change them) so that might save some resources. Also if you got a small typo in some of the options, saving them won’t cause any harm if you notice them, because the site will still run on old rules until you go to permalinks page.

About the is_post_type_archive() bug – I’m not really sure. Is there any kind of pattern at all to that bug so that I could try to replicate it? If not then giving access to the site that it’s happening on would be really helpful (you can contact me @ rolands.atvars [at] gmail [dot] com). I sense that it might be some problem with caching…

Anyway – thanks for the comment and I hope that I will be able to help you :)

November 15, 2010 @ 20:22

Hi. I don’t know if it was just me, but when using wp_get_post_type_archives and setting ‘format’ => ‘option’ it doesn’t include the post_type in the slug. For example: normal use outputs archive links as domain.com/news/2010, but when applying format=option to the function, it outputs domain.com/2010. Format=option is an option for wp_get_archives. I figured this out after a few hours of troubleshooting. Might want to look into fixing that. Otherwise, great plugin.

November 21, 2010 @ 01:41

any chance of getting custom taxonomy archives too? lets say I have a custom post type called recipes and your plugin ads custom psot type archives thats nice but now I also have a custom taxonomy called ingredients. I’d love to have a custom taxonomy archive for that too… would this be possible?

December 14, 2010 @ 12:16

Hi, Atvars
thank you a lot for your great plug-in!
but I can’t activate it on WP 3.1-beta1.
What do I do?

“Fatal error: Cannot redeclare is_post_type_archive() (previously declared in wordpress/wp-includes/query.php:158) in wordpress/wp-content/plugins/custom-post-type-archives/post-type-archives.php on line 323″

December 31, 2010 @ 17:56

Hello!

This plugin is really great!
But I’m having a strange problem. I created three custom posts types and their file pages “-type post-name.php”but only two are functioning, the other returns and gives as the index.php page not found.
Could tell me what might be happening?

Thanks!

January 02, 2011 @ 00:18

Sorry for not being able to answer your questions earlier.

Jason LaRose: I will try to look into it. Thanks for noticing and telling me about it.

Ovidiu: Might do. I’m trying to figure out what should I do with the plugin, because WordPress 3.1 will have most of the functionality of this plugin built in.

tonoro: that might be, because, WordPress 3.1 will include most of this plugins functionality so you don’t really need this plugin (I think this plugin will still give more functionality). I haven’t tested v3.1 yet, but I guess I’ll have to do that soon as it already got to RC1. Thanks for telling me that though.

thomaz vianna: What exactly in ‘Template Pattern’ field? And what is the custom post type name for the post type that doesn’t work? I hope that will help me to replicate the problem. :)

January 02, 2011 @ 14:32

Hi! Thanks for responding. Template pattern is in the
default configuration ‘POST_TYPE. php ‘. I think the problem should
be neither the plugin or the theme I’m doing. I tested the plugin
on localhost and it worked at all post types I created. The problem
is happening when I use on a server. Return to index.php,
regardless of the value of ‘fallback template’ I put two
screenshots of these links: http://migre.me/3naCQ
http://migre.me/3naEa You know what might be happening? Thank you!
P.S. Sorry for my english, I needed the help of google translator
;)

January 02, 2011 @ 16:47

Rolands,

Actually I do not know q may be happening.

I tested on localhost and now another installation did not work. It seems to have a life, works when he wants.

January 02, 2011 @ 17:14

I managed to solve the problem!

Just changed the rewrite option from true to false when I created the custom posts using the plugin type post Custom UI.

Anyway, thank you for your attention.

Congratulations and success to you!

January 23, 2011 @ 02:39

Hi Rolands,

Thanks for the awesome plugin. I know it is going to save me a ton of time. I am having difficulty figuring something out though.

I am using the plugin in conjunction with the custom post type UI plugin and I have it working the way I want except for the use of different templates for each post type. can you send me the steps that allow me to adjust the template for each post type?

Sorry if it is basic. Sometimes the basic stuff gets even the advanced people stumped at times.

February 03, 2011 @ 23:40

Hi Ryan,

Sorry for the late reply. You should be able to do that by:

– going to Settings -> Post Type Archives
– saving Template Pattern as {POST_TYPE}.php

If you do this and if you have a custom post type with name ‘photo’, then this plugin will try to load photo.php from your themes directory. So just edit that file so that it does what you want it to do :)

Hope this helps.

February 04, 2011 @ 15:46

Heya,

thanks for the nice plugin. Was looking for something like this :)

February 11, 2011 @ 14:29

this is the plugin what i am searching for the past couple of weeks. Thanks for plugin and your hard work.

February 15, 2011 @ 14:48

Thanks for the plugin! I can’t seem to get wp_get_post_type_archives working… I’m sure I’m missing something really simple!

If I have I get nothing. What am I missing!? (I’ve tried it in an array to no joy either.) Thanks!

February 15, 2011 @ 14:51

OK, so the comments removed my code… let’s try again. I’ve got this:
<?php wp_get_post_type_archives( ‘post_type=custompostnameorslug&type=monthly’ ); ?>

and get nothing. Thanks!

February 15, 2011 @ 21:33

Thanks Net Zero Home and vamban! I’m glad that you find this plugin useful.

Hi James,

You should use it this way:
< ?php wp_get_post_type_archives('custompostnameorslug', array('type' => ‘monthly’)); ?>

Hope that this works. There is also a FAQ question about this in here (http://wordpress.org/extend/plugins/custom-post-type-archives/faq/).

Please do ask if you have any other problems.

February 23, 2011 @ 21:05

Hey there,

We’re getting a fatal error due to line 381 of your plugin after upgrading to 3.1. Wondering if a fix is imminent or if you have no more interest in continuing development on this project.

Full error:

Fatal error: Cannot redeclare is_post_type_archive() (previously declared in /public_html/wp-includes/query.php:163) in /public_html/wp-content/plugins/custom-post-type-archives/post-type-archives.php on line 384

On http://roughmountainstudios.com. Others are experiencing the same issue.

February 23, 2011 @ 23:16

Hi Ben,

Sorry about that – I should have fixed it earlier. I’ve just pushed the new plugin version live and it should soon be available. The new version is v1.5 -> http://wordpress.org/extend/plugins/custom-post-type-archives/ and it should fix this problem.

Please note that this update renames ‘is_post_type_archive’ function to ‘pta_is_post_type_archive’ because WordPres implements it’s own version of ‘is_post_type_archive’ since v3.1. If you use ‘is_post_type_archive’ function in your theme then you should change it to ‘pta_is_post_type_archive’ because WordPress’s implemented function won’t return correct results if you use this plugin.

I hope your sites didn’t have big downtimes and I really do apologise that I didn’t fix this earlier.

February 24, 2011 @ 17:21

We ran into an issue with this when we did not update the plugin before upgrading to WP 3.1. So we downloaded the previous version from the hosting account and deleted it from the plugin folder. Then, we uploaded the new version. The site is now back up and running fine.

March 03, 2011 @ 00:04

Oh my god you are good. This is seriously the best Custom Post Type-related plugin I’ve ever used. It actually works, it’s not a performance hog, not complicated and not messed up like many, many others…

Great work, very well done!

One small remark: on wordpress.org you say the function is named `is_post_type_archive` and on your site you say `pta_is_post_type_archive` and the latter indeed works. Perhaps you should edit that on wp.org.

peace,

Jay

March 07, 2011 @ 09:03

Fatal error: Cannot redeclare pta_wp_get_archives_filter() (previously declared in /home/bestdiet/public_html/cms/wordpress/wp-content/themes/bestdietpills/functions.php:214) in /home/bestdiet/public_html/cms/wordpress/wp-content/plugins/custom-post-type-archives/post-type-archives.php on line 475

please email me the answer..i cant check this site often

March 07, 2011 @ 15:05

This is great plugin and great explaination Rolands!
Also work normally on my site. Thanks :)

March 09, 2011 @ 11:12

You wrote:
“Paging, feeds and daily/monthly/yearly archives will work for these archives the same way as for other archives!”

But how did “daily/monthly/yearly archives” works?

March 09, 2011 @ 21:36

Thanks for the good words :)

Jay: WP site should say the new function name and I’m not really sure why isn’t it updated. I guess I will have to push the readme file again so that WordPress catches it. Thanks for noticing :)

star: I did send you an email. I hope it helps.

Vatih: Awesome – thanks! :)

Angelo: I hope that you’ll find the answer in the last question on this page: http://wordpress.org/extend/plugins/custom-post-type-archives/faq/ :)

April 16, 2011 @ 15:31

Hi Rolands,

This plugin is fabulous and I absolutely love it. I know how the {POST-TYPE}.php area works but I have a more specific question regarding the template files.

single.php more specifically. I want to have it so that when looking at a single post (custom post type) that I have a previous post link, a “main” link that goes to the main page of the archives, and a next post link at the top. But of course, I don’t want the same “main” page link on all of my custom post archive pages. The singl.php file as it stands now, has the main link going to the home page but I want it to go to the archive main page.

For an example to help explain this better (cuz I think I’m failing) I have two custom content types: news and books.

News is at http://example.com/news and books is at http://example.com/books.

On the news page is the archive listing of all the news posts. But when I click on a single post, (http://example.com/news/new-features) I want a previous post link, the main link to the link to http://example.com/news) and then a next post link.

Then repeat for the books page but using http://example.com/books as the main link.

So, what should I make the new template name be in order for this to work? single-{post-type}.php maybe? I hope I explained it well enough for you.

Thanks so much. Please email me with your suggestions. I’ll forget to check here LOL.

Anastasia V. Pergakis

April 16, 2011 @ 15:35

And I guess, while I’m asking what about the custom content type categories and tag pages? How would I make those work? I don’t know if that’s related to your plugin really, but though I would ask just in case you happened to know if I could make a category_{post-type}.php file and have it work.

Thanks.

April 16, 2011 @ 19:22

I am happy to announce that YES creating a new file called single-{post-type}.php DOES work! I wanted to repost it here in case anyone else wanted to know.

I’m still trying to figure out the category and tag pages. Been trying many different commands in order to get it to work but I can’t find anything to replace the following commands in the archive.php file and single.php files.

the_category
single_cat_title

Any thoughts Rolands or someone else who may have done this?

Rolands: If you want me to type up an addition to your readme/info on how to did everything (especially when I figure it all out), let me know. I’d be happy to. It’s really easy but took me a while to get it to work. :)

April 16, 2011 @ 23:27

Yes, I’m commenting again. I know. I’m probably being super annoying.

It took all day (and most of yesterday) but I FINALLY have my site looking the way I want. It was hard to figure out which function would do what I wanted with custom content types, custom post categories and tags.

But basically, my site looks like I have three seperate blogs! With categories, tags, archives, and feeds. I’m SO happy about that.

Thanks again for a great plugin Rolands! Email me if you want to know how I did it. I don’t want to bog this place down with another super long comment!

April 21, 2011 @ 21:59

Here is a question… I am using your custom post type archive plugin for my 4 different post types. Is there a way to make a merged stream that has all 4 types in one list?

Also, can you make any of these be RSS feeds?

Thanks!

August 04, 2011 @ 14:58

How can i use wp_get_post_type_archives with format=option! The permalink dont put /customposttype/ before date.

thankz!

August 08, 2011 @ 20:03

Anastasia V. Pergakis: sorry for not answering. I absolutely didn’t have any time for the past few months. I’m glad that you got it working at the end!

Cmurockstar: not with my plugin I’m afraid. The simplest way would be for you to use query_posts() function (http://codex.wordpress.org/Function_Reference/query_posts) and setting ‘post_type’ argument to whatever you like.

Adriano: yes – that’s a bug in this plugin. I’ve just commited a fix for it though so a new update should be available soon. Thanks for finding this bug!

August 16, 2011 @ 20:40

Hi Rolands,

Thanks for the great plugin but i keep on getting 404 error while paginating to next archive page. Example: http://www.test.com/archive/page/2

Any suggestion would be a great help.

Thanks!!

August 18, 2011 @ 22:13

Hi Umesh,

Can I ask what settings are you using for the plugin? Do you by any chance have a custom post type archives for pages? This would help me to replicate the issue.

August 23, 2011 @ 14:55

Hi Rolands,

My settings:
URL Base: blank
Use Rewrite Rule: unchecked, FYI tried checked too
Title: blank
Template Pattern: archive-{POST_TYPE}.php
Fallback Template: index.php
Enable Feed Links: checked
Enabled Custom Post Type Archives: abc, xyz, …

and am using wordpress’s
posts_nav_link() or next_posts_link() / previous_posts_link() functions to get the pagination work.

I have been looking for solution for almost 1 week but no luck.

Would be great if you could do something on this.
Thanks in advance

August 25, 2011 @ 18:12

Hi Rolands,

just checking if you were able to find something on the issue… I have been trying all the possible solutions but its not working. I don’t know why this is happening.

September 08, 2011 @ 20:32

I know your changelog says that 1.5.1 should support the option format in wp_get_post_type_archives, but it still doesn’t seem to show quite correctly in my install. It outputs the text value, but not the html around it.

September 20, 2011 @ 03:25

Hi our family loves your excellent website and pls keep it up

September 20, 2011 @ 04:34

Howdy We loves your terrific editorial thank you and pls stick at it

September 20, 2011 @ 04:36

Howdy siblings just loves your awesome article thanks and pls keep the ball rolling

October 03, 2011 @ 09:23

Hey our family just loves your beautiful website thanx and please don’t stop!

October 03, 2011 @ 09:23

Hi There! I just loves your marvelous blog thanks and pls keep it on

October 03, 2011 @ 09:23

Howdy siblings just loves your charming site thanks and please keep it on

October 03, 2011 @ 09:25

Howdy I loves your striking blog thank you and please continue it

October 03, 2011 @ 09:25

Hello We just loves your excellent website and pls don’t stop!

October 17, 2011 @ 10:37

Hey, just wanted to say thanks for the plugin! Did the job for me! :)

I’ve looked at the code … it’s very nice and clean. I didn’t understand everything, but I’d love to. Would you recommend any resources to pick up and learn how to write plugins? I would really appreciate any tips :)

Many thanks!
Dasha

December 13, 2011 @ 00:03

Thanks for your post. Another element is that being photographer involves not only difficulty in capturing award-winning photographs and also hardships in establishing the best digicam suited to your needs and most especially struggles in maintaining the quality of your camera. This is very accurate and noticeable for those professional photographers that are straight into capturing the actual nature’s exciting scenes — the mountains, the actual forests, the wild or even the seas. Going to these exciting places unquestionably requires a camera that can surpass the wild’s severe surroundings.

January 06, 2012 @ 21:37

I’d have to check with you here. That is not one thing I usually do! I love reading a article which will make people believe. Also, thanks for allowing me to provide feedback!

January 22, 2012 @ 05:12

Hello,
As owner of a web business – and after looking for a solution to pagination with custom post types; I came across your plug-in.
THANK YOU so much – it works wonders and I was so pleased to find something it works. Awesome & Amazing. Truly a wonderful plug-in, really :)


What can you say?