【问题标题】:how to Pass custom field value to post query array category field如何传递自定义字段值以发布查询数组类别字段
【发布时间】:2016-06-02 11:18:40
【问题描述】:

我想动态制作医生类别部分。请看看我的查询。我为写入类别名称创建了一个自定义字段。当我写一个类别名称时,然后在页面上显示这些类别的帖子。

<?php $doctors_list = new WP_Query(array(
  'post_type'=>'doctor',
  'posts_per_page'=> -1,
  'order'=>'ASC',
  'doctors_category'=> $doctor_cat
  ));
  $unique = "_doctor_";
  $doctor_cat= get_post_meta(get_the_ID(),'depertment_cat',true);
?>

我试过这个查询但没有用。所以请有人帮助我。 谢谢

【问题讨论】:

    标签: php wordpress wordpress-theming custom-wordpress-pages


    【解决方案1】:
      Try this,
      <?php 
       $doctor_cat= get_post_meta(get_the_ID(),'depertment_cat',true);
    
       $doctors_list = new WP_Query(array(
      'post_type'=>'doctor',
      'posts_per_page'=> -1,
      'order'=>'ASC',
      'category'=> $doctor_cat
       ));
    
       ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多