wordpress query.php,php – WordPress:’post_name’上的WP_Query搜索条件

我正在使用WP_Query(非常标准).一切都很好.

但是,我做了一个特别的修改,其中,如果用户在URL中输入特定的帖子名称,搜索将只返回匹配该post_name值的帖子.

请参阅下面的代码,其中包含有关特定行无效的注释.

$getPeople = array(

'post_type' => 'person','posts_per_page' => -1,// I want this below to only return me the post with this specific value.

// This doesn't error,but doesn't work either.

// I know it seems counter-productive to a 'search' but this particular case requires it.

// This has a hard-coded value at the moment.

'post_name' => 'rebecca-atkinson','orderby' => 'Meta_value','Meta_key' => 'last-name','order' => 'ASC','Meta_query' => array(

array(

'key' => 'gender','value' => $theGender,)

),'tax_query' => array(

'relation' => 'OR',array(

'taxonomy' => 'accent','field' => 'slug','terms' => $theAccent,'operator' => 'IN',),array(

'taxonomy' => 'style','terms' => $theStyle,array(

'taxonomy' => 'age','terms' => $theAge,)

);

$myposts = new WP_Query($getPeople);

?>

非常感谢您的帮助.如果我能看到如何搜索这个特定的’slug’,那就太棒了.

非常感谢,

迈克尔.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值