{"id":919,"date":"2012-12-06T16:04:13","date_gmt":"2012-12-07T02:04:13","guid":{"rendered":"http:\/\/mymonkeydo.com\/?p=919"},"modified":"2012-12-06T16:04:13","modified_gmt":"2012-12-07T02:04:13","slug":"wp-query-inconsistencies-in-query","status":"publish","type":"post","link":"https:\/\/mymonkeydo.com\/wp-query-inconsistencies-in-query\/","title":{"rendered":"WP Query inconsistencies in query"},"content":{"rendered":"
In WordPress, I created a new WP_Query with a few simple args to get a custom post type. \u00a0However, no results came back. \u00a0I could look at the query by checking WP_Query’s\u00a0request property. \u00a0The query, when run in mysql returned the desired rows. \u00a0So what was happening to these rows?<\/p>\n
<\/p>\n
WP_Query’s posts property holds all the posts that will be returned. \u00a0Looking into wp-includes\/query.php, it turned out that I didn’t have read permissions. \u00a0I was trying to show private posts. \u00a0The user needed ‘read_post’ and ‘read_private_posts’ permissions (‘post’ can be replaced with your custom capability).<\/p>\n
On a side note, tax_query does not work in the args if you are retrieving a single post object. \u00a0What determines this? \u00a0It depends on what args \u00a0you send WP_Query. \u00a0If you send it args like ‘name’, ‘p’, ‘page_id’, and some other parameters it will mark it as is_single and it will not perform tax_query! \u00a0This took me a while to find.<\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[2],"tags":[54,64],"yoast_head":"\n