0

In Wordpress, I have a CPT with Doctors, with 2 taxonomies: medical specialties and medical care agreements.

I'm building a site for a small clinic, and I need to create a appointment form, where people chose the doctor, the medical specialty and the respective medical care agreement available.

https://i.stack.imgur.com/vgxMj.jpg

How can I fill the multiple selects dynamically, where the users filters through Specialty->Doctor->Agreement

1 Answers1

0

Select can be filled dynamically using jQuery/Ajax How to change options of <select> with jQuery?

For advance taxonomy queries check this https://code.tutsplus.com/tutorials/wp_query-arguments-taxonomies--cms-23090

For generating drop-down for specialty:

$terms = get_terms( array(
    'taxonomy' => 'specialty',
    'hide_empty' => false,
) );

This will output array which you can use to generate select.

More info about function and its parameters: https://developer.wordpress.org/reference/functions/get_terms/

For generating drop-down for doctor with select specialty

$args = array(
    'post_type' => 'doctor',
    'tax_query' => array(
        array(
            'taxonomy' => 'specialty',
            'field'    => 'slug',
            'terms'    => 'eye',
        ),
    ),
);
$query = new WP_Query( $args );

This will output array which you can use to generate select.

More info about function and its parameters: https://codex.wordpress.org/Class_Reference/WP_Query

For 3rd Drop-down:

Not clear

Community
  • 1
  • 1
Ajit Bohra
  • 373
  • 3
  • 9
  • My problem is filling the selects dynamically with CPT/taxonomies relationships – user3375840 Nov 23 '16 at 10:46
  • Can you provide more details on this – Ajit Bohra Nov 23 '16 at 15:43
  • Basically, I want to buld a form with 3 selects. One with the specialty. When the user choses the specialty, another select gets populated with doctors associated with that specialty. And then, the last select with the medical agreement, associated with the specialty. – user3375840 Nov 23 '16 at 18:17
  • So flow / relation is user get list of specialty when user select any value based on that next drop down is populated which shows doctors with that specialty. Doctor to specialty relations is clear how medical agreement will be associated with specialty ? Taxonomies are a relationship between posts ! – Ajit Bohra Nov 26 '16 at 11:35