Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm working with the new custom post type archives in 3.1 and I noticed that when my post type has 0 posts, the archive for the type results in a 404. Looking at the order of hooks being processed, it's redirecting to the 404 template before even processing my archive-{post_type}.php template and reaching the conditional for available posts.

Reading various articles and questions here had clued me in on flushing the permalink state after creating my types. This shouldn't be an issue, however, as the archive page works if posts for the type exist. I even went as far as setting my has_archive value to the post type slug rather than just true to no avail.

Is there a way to force the archive template to be loaded and not generate a 404 regardless of post count while keeping the query in place?

share|improve this question
    
One method I'm trying is to use the template_redirect action to determine if the post_type matches the requested one and redirect to the archive-{post_type}.php template. Of course, this also means hooking anything else that may act upon the 404 (title, other content modifers, etc). I'm hoping there's a more logical way of fixing this as it seems like a bandaid more than anything. –  BigRedPimp Mar 10 '11 at 17:16
    
I have the exact same problem in 3.1. A custom post type with no posts results in a 404 error message. Help please! –  EddyR Mar 23 '11 at 7:12
add comment

3 Answers

up vote 2 down vote accepted

An FYI for those coming back to this question, this was fixed in 3.2: http://core.trac.wordpress.org/ticket/17316

share|improve this answer
add comment

resave permalink do the job for me

share|improve this answer
    
That doesn't seem to work in this case. I've saved the permalink options plenty of times with the same results. I've even used flush_rewrite_rules() and have seen the same result. –  BigRedPimp Mar 10 '11 at 0:52
add comment

Try the Custom Post Type Archives plugin. http://wordpress.org/extend/plugins/custom-post-type-archives/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.