简短回答要获取帖子状态,您需要JOIN
基于post_id
你从wpm1
或wpm2
并扩展您的WHERE
子句使用该联接数据。
建议另一方面,您可以使用WP_Query
处理此内容。请参见下面的快速示例。我强烈建议在将此代码添加到您的站点之前对其进行测试。
<?php
$args = array(
\'fields\' => \'ids\',
\'posts_per_page\' => 1, // This is a heavy-handed approach to limit result to one
\'meta_query\' => array(
array(
\'key\' => \'review_product\',
\'value\' => $this->post->ID,
\'compare\' => \'=\',
),
),
);
$query = new WP_Query( $args );
$all_ids = $query->posts[0]; // Most likely want to change this to a foreach so you can find the right value
$args2 = array(
\'fields\' => \'ids\',
\'meta_query\' => array(
array(
\'key\' => \'review_rating\',
\'value\' => $all_ids,
\'compare\' => \'=\',
),
),
);
$query2 = new WP_Query( $args2 );
return $query2->post_count;