1 comment

  1. In this case, as you mix pretty permalinks with request parameters, I would use the $_GET variables in your query.

    $query_args_meta = array(
        'posts_per_page' => -1,
        'post_type' => 'nc_property',
        'meta_query' => array(
            'relation' => 'AND',
            array(
                'key' => 'nc_bedrooms',
                'value' => sanitize_text_field( $_GET['bedrooms'] ),
                'compare' => 'LIKE'
            ),
            array(
                'key' => 'nc_type',
                'value' => sanitize_text_field( $_GET['type'] ),
                'compare' => 'LIKE'
            ),
            array(
                'key' => 'nc_location',
                'value' => sanitize_text_field( $_GET['location'] ),
                'compare' => 'LIKE'
            )
        )
    );
    

    Be sure to use the proper sanitation, depending on your needs, or using a function that checks for whitelisted values of the $_GET data.

    Also check your function of the conditionals – you just alter the query if it is a search request (using s as search parameter), or alter the if statement.

Comments are closed.