One particular post type causes a query error unless I also include taxonomy
-
I’m a bit baffled why a custom post type causes an error when I query for it, unless I also include taxonomy terms.
This causes a 500 internal error.
<?php $loop = new WP_Query( array( 'post_type' => 'venue', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); ?>
However, I can get ‘venue’ to loop but only if I include a taxonomy query.
<?php $loop = new WP_Query( array( 'post_type' => 'venue', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'tax_query' => array( array ( 'taxonomy' => 'venue-affiliations', 'field' => 'slug', 'terms' => 'ADAA', ) ), ) ); ?>
So if I include a taxonomy query the loop works. If the taxonomy isn’t there then the page load crashes once it gets to the loop. But not all venues have an affiliation, so I can’t get those to display.
I have another custom post type ‘artists’ and the above code works perfectly when I loop that.
So I thought maybe it had to do with the way the custom post type was registered in functions.php but both ‘artists’ and ‘venue’ setup are nearly identical.
Any clues why this might be happening?
- The topic ‘One particular post type causes a query error unless I also include taxonomy’ is closed to new replies.