正如@Mark Kaplen提到的,WP API可以显示执行的查询
下面是一个简单的查询,使用模板中的API查看发生了什么:
<?php
/*
* Template Name: Troubleshooting
*/
$args = array(
\'post_type\' => \'post\',
\'tax_query\' => array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'category\',
\'field\' => \'slug\',
\'terms\' => array( \'uncategorized\' ),
),
array(
\'taxonomy\' => \'post_tag\',
\'field\' => \'slug\',
\'terms\' => array( \'red\' ),
),
),
);
$query = new WP_Query( $args );
echo $query->request;