mabuc
says
Hello,
I have a cpt services and each post I added exclude checkbox. My question/problem is how can I get the checkbox exclude value in a loop using a new wp_query? below are the code I used..
$args = array( 'post_type' => 'gallery', 'post__not_in' => array($exclude_id), 'paged' => $paged );
$wp_query = new WP_Query( $args );
$exclude = get_post_meta( $wp_query->post->ID, "exclude", true );
if($exclude == "on") {
$exclude_id = $wp_query->post->ID;
}
I want to get the $exclude_id value and add it in the $args statement but it’s not working.. can anyone help me with this..
thank you very much!
fAntasticmE
says
you better use it in the loop with an if statement
if(!get_post_meta(post->ID, "exclude",true)){
//do stuff
}
mabuc
says
fAntasticmE said
you better use it in the loop with an if statementif(!get_post_meta(post->ID, "exclude",true)){ //do stuff }
that won’t work. It should be
if(get_post_meta( $post->ID, "exclude", true )) { }
I used this before but I am adding a dynamic class=”last” if it’s 2 cols, 3 cols and 4 cols.. so I decided to add the exclude in the $arg statement…