使用 WordPress meta_query 查找 post 标题
Using WordPress meta_query to find the post title
我有以下内容,它与 meta_query 一起使用,因为它传递了自定义元属性,但我正在努力让它只搜索自定义 post 类型的标题。
<?php
$args = array(
'post_type' => 'team',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'title',
'compare' => 'LIKE',
'value' => $teamName
)
)
);
?>
这应该可以正常工作,使用 WP 查询的搜索参数,它还搜索标题:
<?php
$args = array(
'post_type' => 'team',
's' => $teamName,
);
?>
我有以下内容,它与 meta_query 一起使用,因为它传递了自定义元属性,但我正在努力让它只搜索自定义 post 类型的标题。
<?php
$args = array(
'post_type' => 'team',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'title',
'compare' => 'LIKE',
'value' => $teamName
)
)
);
?>
这应该可以正常工作,使用 WP 查询的搜索参数,它还搜索标题:
<?php
$args = array(
'post_type' => 'team',
's' => $teamName,
);
?>