Support » Fixing WordPress » Custom Post Type Loop Exclude

  • I have a working custom loop that calls through my Members custom post type. Each member has an option for meta_key’s of President, Sec/Treasurer, etc. I want to exclude 4 of those custom fields through this loop. They all are a single checkbox and output a value of on.

    $temp = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query("post_type=sbms_members&post_status=publish&posts_per_page=10&orderby=title&order=asc&meta_key=sbms_board_member&meta_key!=sbms_president");
    while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

    I’ve also tried:

    $wp_query = new WP_Query("post_type=sbms_members&post_status=publish&posts_per_page=10&orderby=title&order=asc&meta_key=sbms_board_member&meta_key=sbms_president&meta_compare=!=&meta_value=on");

    This will actually take away all the posts as the meta_key board_member’s value=on when checked.

    Maybe the problem is how the set up is for the custom post, is there a way to set the value to a checkbox? This is what I have within my functions.php to set up the post type custom fields:

             'name' => 'President',
             'id' => $prefix . 'president',
             'type' => 'checkbox'
Viewing 1 replies (of 1 total)
  • Ok I’ve figured out how to output the value and it’s now different for each case, but I’m still trying to figure out if it’s possible to filter out multiple meta_key’s based on their value.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Type Loop Exclude’ is closed to new replies.