Pull a post based on a meta value in a custom post type

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.

Read More

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.

Related posts

Leave a Reply

1 comment

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