0

我想通过他们的座位容量搜索餐厅。我将从下拉列表中选择一个数字,我必须在最小和最大座位容量之间显示餐厅。我试过下面的代码。但它总是没有结果。

$_seating_capacity  = $_GET['seating_capacity'] != '' ? $_GET['seating_capacity'] : '';
$_standing_capacity = $_GET['standing_capacity'] != '' ? $_GET['standing_capacity'] : '';
$_neighborhood      = $_GET['neighborhood'] != '' ? $_GET['neighborhood'] : '';
// Start the Query
$v_args = array(
    'post_type'  => 'Dinings', // your CPT
    'meta_query' => array(
        'relation' => 'AND',
        array(
            'relation' => 'OR',
            array(
                'relation' => 'AND',
                array( 'key'     => 'min_capacity_sit',
                       'value'   => $_seating_capacity,
                       'compare' => '=>',
                       'type'    => 'NUMERIC',
                ),
                //AND Conditation
                array( 'key'     => 'max_capacity_sit',
                       'value'   => $_seating_capacity,
                       'compare' => '<=',
                       'type'    => 'NUMERIC',
                )
            ),

            //OR Conditation
            array( 'key'     => 'max_capacity_stand',
                   'value'   => $_standing_capacity,
                   'compare' => '<=',
                   'type'    => 'NUMERIC',
            )
        ),
        //AND Conditation
        array( 'key' => 'neighborhood', 'value' => $_neighborhood, 'compare' => 'Like', ),
    )
);
4

1 回答 1

0

您使用的比较中有错误,=>但语法为>=.

这也是一个很好的查询。如果还有其他问题,我建议您将每一步都注释掉。并且一次打开 1 步调试,也一次打开一步。

WP_Query 的文档

于 2018-10-25T10:54:03.047 回答