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

<?php
    $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;?>
                        </select>
                      </div>
                      <div class="form-group">
                        <input type="text"  name="doctor" class="form-control" placeholder="Search By Name">
                      </div>
                      <button type="submit" class="btn btn-default">Submit</button>
                </form>
            </div>
        </div>


    </div>
</div>

Read more here: filter wordpress post by custom fields value


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: