Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter roma-glushko

    (@roma-glushko)

    Oooh, yeah I forgot about apply_filter():

    function apply_filter($other){
    	$args = array(); // подготовим массив
    
        if($_GET) {
            $args['meta_query'] = array('relation' => 'AND'); // отношение между условиями, у нас это "И то И это", можно ИЛИ(OR)
            global $wp_query;
    
            if (!empty($_GET['fio'])) $args['s'] = sanitize_text_field($_GET['fio']);
    
            if (!empty($_GET['hospital']) && is_numeric($_GET['hospital']) && intval($_GET['hospital']) > 0) {
                $args['meta_query'][] = array(
                    'key' => 'doctor-hospital',
                    'value' => $_GET['hospital'],
                );
            }
    
            if (!empty($_GET['profession']) && is_numeric($_GET['profession']) && intval($_GET['profession']) > 0) {
                $args['meta_query'][] = array(
                    'key' => 'doctor-profession',
                    'value' => $_GET['profession'],
                );
            }
    
            if (!empty($_GET['sex']) && in_array($_GET['sex'], array('0', '1'))) {
                $args['meta_query'][] = array(
                    'key' => 'doctor-sex',
                    'value' => $_GET['sex'],
                );
            }
    
            if (!empty($_GET['range']) && in_array($_GET['range'], array('0', '1'))) {
                $args['meta_query'][] = array(
                    'key' => 'doctor-range',
                    'value' => $_GET['range'],
                );
            }
    
            if (!empty($_GET['title'])) {
                $args['meta_query'][] = array(
                    'key' => 'hospital-title',
                    'value' => sanitize_text_field($_GET['title']),
                    'compare' => 'LIKE',
                );
            }
    
            if (!empty($_GET['address'])) {
                $args['meta_query'][] = array(
                    'key' => 'hospital-address',
                    'value' => sanitize_text_field($_GET['address']),
                );
            }
    
            if (!empty($_GET['phone'])) {
                $args['meta_query'][] = array(
                    'key' => 'hospital-phone',
                    'value' => sanitize_text_field($_GET['phone']),
                );
            }
        }
    	return array_merge($args, $other);
    }
Viewing 1 replies (of 1 total)