如何将自定义字段值传递给 post 查询数组类别字段

how to Pass custom field value to post query array category field

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

<?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);
?>

我试过这个查询但没有work.So请有人帮助我。 谢谢

  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
   ));

   ?>