0

I'm trying to filter out 'properties' on a page based on whether they are vacation or long-term rentals. Right now, the results of the following query displays all properties, not just either vacation or just long-term rentals. Am I missing something super obvious?

$args = array(
        'post_type' => 'property',
        'meta_query' => array(
            array(
                'key' => 'rental_type',
                'value' => 'Vacation'
            )
        ),
        'posts_per_page' => $properties_per_page,
        'paged' => $paged
    );
2
  • 1
    Looks fine to me. Are you certain your post_type and key names are correct?
    – vancoder
    Commented Aug 16, 2013 at 23:32
  • positive, everything else is working fine
    – ColoursB
    Commented Aug 17, 2013 at 16:03

1 Answer 1

0

I think you don't have to use meta_query.

Simply use the code like shown below:

$args = array(
        'post_type' => 'property',
        'meta_key' => 'rental_type',
        'meta_value' => 'Vacation'
        'posts_per_page' => $properties_per_page,
        'paged' => $paged
    );

Also you got to get the value of $properties_per_page before this query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.