I need to query my pages to display on blog posts. But not all pages are going to be displayed so I've use metabox and create conditional checkbox if its going to be displayed or not.
My problem is when I query the post and pages, it doesn't show the posts/pages that are allowed to be shown on the blog page.
Assume that the meta_value is 1 which is set not to display and meta_value 0 is set display.
Below is my code:
$args = array(
'post_type' => array('post', 'page' ),
'meta_key' => 'gz_checkbox',
'meta_value' => '1',
'meta_compare' => '!='
);
query_posts($args);
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'no-results', 'index' ); ?>
<?php endif; ?>