3

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

1 Answer 1

3

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.

3
  • On the other hand, using a 404-posttype.php like single-posttype.php might be easier to understand for the next developer.
    – fuxia
    Commented Dec 12, 2012 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? Commented Dec 12, 2012 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.
    – fuxia
    Commented Dec 12, 2012 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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