Dee*_*a B 2 wordpress categories
我正在尝试获取这些类别中帖子的所有帖子 ID(关系 OR):10,11,12,13,14 以及某些额外属性。然而我的问题是类别。
我的 wp_query 的 args 数组如下:
$args = array(
'orderby' =>'ID',
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'category__in' => array('10','11','12','13','14'),
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'joke_type',
'value' => $type,
'type' => 'CHAR',
'compare' => '='
),
array(
'key' => 'joke_rating',
'value' => 3,
'type' => 'SIGNED',
'compare' => '>='
)
),
'fields' => 'ids'
);
Run Code Online (Sandbox Code Playgroud)
这只会获取类别 10 中的帖子(或我在数组中放在第一位的 ID)。我也尝试过:'category__in' => '10,11,12,13,14'和'category' => '10,11,12,13,14'都'cat' => '10,11,12,13,14'表现相同。
知道为什么会发生这种情况吗?
数组中的类别 IDcategory__in应该是整数而不是字符串。
改变:
'category__in' => array('10','11','12','13','14'),
Run Code Online (Sandbox Code Playgroud)
到:
'category__in' => array( 10, 11, 12, 13, 14 ),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5926 次 |
| 最近记录: |