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
    );
  • 1
    Looks fine to me. Are you certain your post_type and key names are correct? – vancoder Aug 16 '13 at 23:32
  • positive, everything else is working fine – ColoursB Aug 17 '13 at 16:03
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, privacy policy and cookie policy

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