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 created a new custom post type called event, which works fine.

I also created a custom 404 page template, which is shown if a event/page/post is not found.

But now the hard part, i want to create a custom 404 page for event post type. So this 404 page is only shown if a event is not found. But the default 404 page should still work with posts or pages.

Thanks

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Two options:

  1. Use conditional code inside of 404.php, to output different content/markup for the post-type
  2. Intercept the template at template_redirect, and include a separate template file for a 404 for the post-type.

Personally, I'd go with option 1, as it is easier and more intuitive.

share|improve this answer
    
On the other hand, using a 404-posttype.php like single-posttype.php might be easier to understand for the next developer. –  toscho Dec 12 '12 at 21:47
    
But the Template Hierarchy doesn't account for anything other than 404.php, so support would have to be added by filtering template_include; thus I'm not sure how intuitive it would be for a subsequent developer? –  Chip Bennett Dec 12 '12 at 22:53
    
You could call that file from 404.php too (and return; then), so implementation details are rather open. I had the file list in mind. –  toscho Dec 12 '12 at 23:02
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.