404 Pages despite content being found?

I find myself in the unenviable position of trying to debug a copy of someone else’s pretty complicated WordPress site and have run into a bizarre problem. Every url on the site (including the admin login) is being sent to the 404 template by *wp-includes/template-loader.php*.

Examining the *$wp_query* object for the page query I’ve found that the page content is present in *$wp_query->queried_object*, but *$wp_query->is_404* is consistently set to true.

This appears to be because of *$wp_query->request* which is set to

*SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND (wp_posts.ID = ‘[POST-ID]’) AND wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’) ORDER BY wp_posts.post_date DESC LIMIT 0, 4*

The [POST-ID] value is correct for the requested page, but the query is returning nothing because of *wp_posts.post_type = ‘post’* – all the pages have their post_type set to ‘page’ rather that post.

Can anyone offer any guidance on resolving this?

1 Comment

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer