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

I want to make doctors_category section dynamically. Pls take a look my query. i created a custom field for write category name. And when i write a category name then show those category post on page.

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

I tried this query but didn’t work.So please someone help me.
thanks

Related posts

Leave a Reply

1 comment

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