1

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.

2

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' ))
);?>
  • 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

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.