3

I have a weird problem when creating custom post types. Everything works, the archive page shows the posts and the posts show their content, but for both the title of the site says, "Page not found."

You can see an example at http://coachingforliteracy.org/events/.

I've flushed the permalinks, which is why the pages load their content, but there is still some disconnect. Any thoughts?

  • 2
    Seems that there is something setting $wp_query->is_404 to true when $wp_query->get('post_type') == 'events'. Asserting this because body_class() also output 'error404'. Try to disable plugins or switching theme. Also try to debug the $wp_query object when post_type == 'events'. – gmazzap Sep 19 '13 at 21:21
  • @G.M. Ok, thanks. I'll see what I can find out. It's happening across multiple sites, and the theme is the most common element so maybe that's the cause. – Josh Hudnall Sep 20 '13 at 21:34
1

Hopefully this will provide some answers to anyone who runs into a similar problem.

I had copied/created a (poor) function in my functions.php file that was looking for specific templates and if they were not found it would set $wp_query->is_404 = TRUE and that was the cause of the problem.

Of course, the higher-level answer is let WordPress work for you. If you structure your template files correctly, you don't need to look for them yourself.

  • My guess was a predition, I can see... :) – gmazzap Oct 8 '13 at 22:25
  • @G.M. It was. Thanks for pointing me in the right direction. I don't know if it matters, but if you want to add it as an answer, I'll mark yours as correct. – Josh Hudnall Oct 8 '13 at 22:28
  • No, it's absolutely not necessary. Your answer is perfect. However thanks. :) – gmazzap Oct 8 '13 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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