Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to display a post, from a custom post type based on a meta value in that post type, in this case a checkbox that says "if this is checked show it on the front page.

Usually I write a query using meta_key = > front_event value => true. But this does not work for custom post types.

So I have this:

<?php 
    $event =array(
    'post_type' => 'Events',
    'posts_per_page' => 1,
    'order' =>'DESC',
    'meta_query' => array( array(
            'key' => 'front_event',
            'value' => true ))
    );?>

This also does not work. Can anyone tell me what I should be doing differently?

Thank you!

Nadine.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Try to wrap true with quotes

<?php 
$event =array(
'post_type' => 'Events',
'posts_per_page' => 1,
'meta_query' => array( array(
        'key' => 'front_event',
        'value' => 'true' ))
);?>
share|improve this answer
    
That totally worked. See, that one piece of syntax would have driven me nuts for a while. :) Thank you Asel! Nadine –  Nadine Sep 9 '11 at 21:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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