这个found_posts 的属性WP_Query class是您要查找的内容,它是为当前查询找到的帖子数量。然而,你有一个0 因为你设置了no_found_rows (在$query 阵列)至true, 这意味着将不计算其中的金额。一、 e。
WordPress不会附加SQL_CALC_FOUND_ROWS 到用于查询帖子的SQL命令。否则,命令将类似于:SELECT SQL_CALC_FOUND_ROWS {the rest of the query}
不会执行WordPressSELECT FOUND_ROWS() 之后,posts查询完成。当它未执行时found_posts 属性将为零(0).
因此,请拆下no_found_rows 从$query 数组,以及$results->found_posts 将具有适当的值:
$query = array(
\'post_type\' => \'shop_coupon\',
\'meta_key\' => \'special_key\',
\'fields\' => \'ids\',
);