0
我在我的网站上使用utimate成员插件。对于每个成员(作者),我有一个字段来存储成员性别。 (Homme/Femme)。查询帖子由作者性别
数据存储在我的数据库中,位于wp_usermeta内。
元键是“性别”,元值是“Homme”或“Femme”。
我想写一个WP-查询,显示从所有作者的所有帖子,但只是“男士”的作者,而另一只“女人”。
这里是我的WP-查询按性别显示未经过滤的所有帖子:
<?php $custom_query_args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'post_status' => 'publish',
'order' => 'DESC',
'orderby' => 'date',
);
$custom_query = new WP_Query($custom_query_args); ?>
工作正常。
这是我迄今为止试过的只有“Homme”性别的帖子,但它不工作......我想我需要添加一个引用来发布作者ID的地方,但我找不到解决方案。
<?php $custom_query_args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'gender',
'value' => 'Homme',
'compare' => '='
),
),
'order' => 'DESC',
'orderby' => 'date',
);
$custom_query = new WP_Query($custom_query_args); ?>
我不知道是否有与插件本身上来它的一种方式,但我敢肯定它可以用一个简单的WP查询来完成。
有人可以帮我吗?
谢谢。