tags:

views:

7

answers:

1

I have custom post type items in my theme. They represent projects in portfolio. I have a custom field checkbox that sets the option "Featured" for every single project. So, when the project is featured, it's being shown on the main page of the site. If the "Featured" checkbox is unset, the project is visible only on the portfolio page. What I need now is to query only featured projects to show them on the main page. I use this code to show the posts but I don't know how to add the option to get only posts with the "Featured" custom field set to True.

$args = array(
        'post_type' => 'project',
        'post_status' => 'publish');
    $projects = new WP_Query($args);
    if ($projects->have_posts()) {
        while ($projects->have_posts())
... Show the project info here

What can I do about this?

+1  A: 

Add this to your array.

   meta_key => 'featured',
   meta_value => 'true'
philmadelphia