I have a site that has been running for a year that uses custom content types with archive pages. These archive pages uses data generated by WP_Query to show custom content. Recently these pages have all stopped working.
I have found that copying the code to a non-template page works OK.
For example, there is a page hidden link which shows the content type 'venue' and which is generated using the template archive-venue.php - the template contains the code
$args = array(
'post_type' => array( 'venue' ),
'order' => 'ASC',
'posts_per_page'=>-1 ,
'orderby' => 'title',
);
global $post;
$query = new WP_Query( $args );
//echo "<pre>"; var_dump($query);
// The Loop
if ( $query->have_posts() ) {
When generated in this way the WP_Query returns
........
["request"]=>
string(412) "SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'venue' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND wp_posts.post_type <> 'venue' AND wp_posts.post_type <> 'meeting' AND wp_posts.post_type <> 'hospital' AND wp_posts.post_type <> 'news' AND wp_posts.post_type <> 'school-information' AND wp_posts.post_type <> 'carousel' ORDER BY wp_posts.post_title ASC "
["posts"]=>
array(0) {
}
.....
(Note that the WHERE clause contains both wp_posts.post_type = 'venue' and wp_posts.post_type <> 'venue')
On the other hand if I copy the same code to a temporary non-template page it returns
["request"]=>
string(188) "SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'venue' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_title ASC "
["posts"]=>
array(27) {
[0]=>
object(WP_Post)#14701 (24) {
["ID"]=>
int(4979)
["post_author"]=>
string(3) "124"
["post_date"]=>
string(19) "2019-05-01 11:08:44"
["post_date_gmt"]=>
string(19) "2019-05-01 10:08:44"
I don't know whether this is a WP bug or a Toolset bug. However I've noticed that some of the Views on template pages have stopped working too.
I notice that this issue happens when a user is logged-in, not when a guest visits the archive, and it appears related to Access, but I need to do some testing to confirm.
I won't do anything on your live site, I'm taking a copy to test with.
I'll update again when I've done some more testing.