filter wordpress post by custom fields value

i am new in wordpress.i want to make custom search filter form. I want to display results of doctors after searching two field. i have no idea how write code to display the result. following is the form code

    $args = array(
        'post_type'   =>  'department',
        'orderby'     =>  'date',
        'order'       =>  'DESC',

    $loop = new WP_Query( $args );


<!-- Stats -->
<div class="stats" style="background: url('images/DSC_4575.jpg');">
    <div class="container">
        <div class="row form-container">
            <div class="col-md-offset-4 col-md-4">
                <h2 class="block-title">Find a Doctor</h2>
                <form action="" method="get">
                      <div class="form-group">
                        <select name="department" class="form-control">
                            <option value="">Search By Department</option>
                            <?php if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();?>
                                <option value="<?php the_ID();?>"> <?php the_title();?> </option>
                            <?php endwhile; endif;?>
                      <div class="form-group">
                        <input type="text"  name="doctor" class="form-control" placeholder="Search By Name">
                      <button type="submit" class="btn btn-default">Submit</button>


Read more here: filter wordpress post by custom fields value

Leave a Reply

Your email address will not be published. Required fields are marked *