Вывод отсортированных постов по кастомным полям

Подскажите в чем тут проблема: задача стоит вывести посты в полях которых есть значение из чекбокса, посты вроде находит, но когда применяю фильтр, они не выводятся, а остается просто самый первый пост рубрики

`<?php


        $args =  array(
            'orderby'      => 'name',
            'order'        => 'ASC',
            'posts_per_page' => 3,
            'post_type' => 'post',
            'post_status' => 'publish',
            'cat' => 29,
        );
        $query = new WP_Query($args);

        ?>

            <div class="container">
        <?php if ($query->have_posts() ) ?>
        <h2><?php echo 'Помещения'; ?> </h2>

                <form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter">
                <div class="filter">
                    <p>Подбор объекта</p>
                    <div>
                        <p>Тип помещения</p>
                        <div>
                            <div>
                                <input type="checkbox" value="Офис" id="ofice" name="date">
                                <label for="ofice" value="Офис">Офис</label>
                            </div>
                            <div>
                                <input type="checkbox" value="Свободное назначение" id="freed" name="date">
                                <label for="freed" value="Свободное назначение">Свободное назначение</label>
                            </div>
                            <div>
                                <input type="checkbox" value="Торговое помещение" id="merc" name="date">
                                <label for="merc" value="Торговое помещение">Торговое помещение</label>
                            </div>
                        </div>

                    </div>
                    <div>
                        <p>Площадь</p>
                        <select>
                            <option value="Тип">от 50</option>
                            <option value="Плащадь">51 - 100</option>
                            <option value="Цена">101 - 150</option>
                            <option value="Цена">151 - 200</option>
                            <option value="Цена">от 200</option>
                        </select>
                    </div>
                </div>

                    <button>Apply filter</button>
                    <input type="hidden" name="action" value="myfilter">
                </form>
                <div class="list-title">
                    <div class="list-item"><span>Фото</span></div>
                    <div class="list-item"><span>Корпус</span></div>
                    <div class="list-item"><span>Тип</span></div>
                    <div class="list-item"><span>Площадь</span></div>
                    <div class="list-item"><span>Стоимость</span></div>
                    <div class="list-item"><span>Планировка</span></div>
                </div>


        <?php
        while( $query->have_posts() ): $query->the_post();
            $id = get_the_ID();
            $description = get_post_meta($id)['opisanie'];
            $favourites = get_post_meta($id)['checkbox_favourites'];
            $typeOfRoom = get_field('tip_pomeshheniya', $id);
            $gallery = get_post_meta($id)['fotogalereya'];
            $officeNumber = get_post_meta($id)['nomer_ofisa'];
            $price = get_post_meta($id)['czena'];
            $layout = get_post_meta($id)['planirovka'];
            $area = get_post_meta($id)['ploshhad'];

            ?>
                <div id="response">
                    <div class="post-list">
                        <div class="list-item">
                            <img src="<?php echo wp_get_attachment_image_url($gallery[0], 'full'); ?>" alt="" />
                        </div>
                        <div class="list-item">
                            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                        </div>
                        <div class="list-item">
                            <span><?=$typeOfRoom[0];?></span>
                            <!--                        --><?php //var_dump($typeOfRoom);?>
                        </div>
                        <div class="list-item">
                            <span><?=$area[0];?> м²</span>
                        </div>
                        <div class="list-item">
                            <span>Стоимость:</span>
                            <span> <?= $price[0]?> руб. </span>
                        </div>
                        <div class="list-item">
                            <img src="<?php echo wp_get_attachment_image_url($layout[0]); ?>" alt="" />
                        </div>
                        <div class="list-item">
                            <button class="list-item-btn">Подробнее</button>
                        </div>
                    </div>
                </div>

            <?php endwhile; wp_reset_postdata(); ?>`

////////////////////////////
      jQuery(function($){
                    $('#filter').submit(function(){
                        var filter = $('#filter');
                        $.ajax({
                            url:filter.attr('action'),
                            data:filter.serialize(), // form data
                            type:filter.attr('method'), // POST
                            beforeSend:function(xhr){
                                filter.find('button').text('Processing...'); // changing the button label
                            },
                            success:function(data){
                                filter.find('button').text('Apply filter'); // changing the button label back
                                $('#response').html(data); // insert data
                                console.log( data)
                            }
                        });
                        return false;
                    });
                });





    function misha_filter_function(){

    $args = array(
        'post_type'  => 'post',
        'meta_query' => array(
            array(
                'key'     => 'tip_pomeshheniya',
                'value'   => $_POST['date'],
                'compare' => 'LIKE'
//                'compare' => 'NOT LIKE'
            )


        )
    );

//
//    $fewfew = get_posts($args);
//    var_dump($fewfew);




    $query = new WP_Query($args);
    if( $query->have_posts() ) :
        while( $query->have_posts() ): $query->the_post();
    var_dump($query);


        endwhile;
        wp_reset_postdata();
    else :
        echo 'No posts found';
    endif;

    die();
}

Ответы (0 шт):