最好的方法是WP_Query
$query = new WP_Query(
\'post_type\' => \'post\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'my_custom_tag\',
\'slug\' => \'slug\',
\'terms\' => array( \'my_tag_slug\' ),
\'operator\' => \'in\',
),
)
);
您应该像这样执行ajax回调
add_action( \'wp_ajax_my_action\', \'my_action\' );
function my_action(){
//my custom code ...
}