WordPress.org

Ready to get started?Download WordPress

Forums

Retrieve Custom Fields in custom Query? (1 post)

  1. kettlewell
    Member
    Posted 2 years ago #

    I'm following this tutorial:

    http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-2-advanced-fields/

    to create a checkbox group in a meta box.

    The box is created, data is getting saved, custom sorts/filters working, etc...

    But what I can't for the life of me figure out, is how to go about creating a query with the custom fields.

    My end goal is to create an archive page of posts that have a checkmark in the checkmark group.

    This is what I have right now -- where have I strayed?

    $args =  array (
    		  'post_type' => 'post',
    		  'meta_query' => array (
    			array(
    			      'key' => 'my_checkbox_group',
    			      'value' => 'my_checkbox_value',
    			      )
    			)
    		  );
      $query = new WP_Query($args);

    When I do print_r($query), there are no posts found for this query (and I verifed that I have several posts with "my_checkbox_value" checked...

    Thoughts?

Topic Closed

This topic has been closed to new replies.

About this Topic