按帖子标题获取帖子(任何标题匹配并作为OR条件)

时间:2017-01-02 10:10:49

标签: php mysql wordpress

我通过特定的帖子类别获得帖子,如果任何类别匹配,那么它将获得记录。现在我想通过获取帖子添加另一个字段(按标题发布)。但是当任何类别与OR条件不匹配而不是AND条件时,它应该有效。

代码

$cat_array =  array();
$args = array(
    'post_type' => 'cv',                        
    'category__in' => $cat_a
);

$the_query = new WP_Query( $args );

尝试 -

$cat_array =  array();
$args = array(
    'post_type' => 'cv',                        
    'category__in' => $cat_a,
    'post-title' => $titleName //doesn't work
    'title' => $titleName //doesn't work
    's' => $titleName //don't know about it
);

$the_query = new WP_Query( $args );

实施例

Table records

Record - 1
Category posttitle
1       A


Record - 2
Category posttitle
2       B

Record - 3
Category posttitle
3       C

input - 
category - 1,2
title = 'anything'
output - record1, record2


input
category - 2,3
title = 'anything'
output - record2, record3

input
category - 4,5
title = 'C'
output - record3

0 个答案:

没有答案