I'm making one page website and I added a custom field on "Page" post type that asks "Use this page as a section:" Yes or No(with dropdown). I called all pages on template-onepage.php(custom template) using wp query
<?php $args = array( 'post_type' => 'pages', 'order' => 'ASC', 'posts_per_page' => 50, 'meta_query' => array( 'key' => 'field_5505a81b83234', // field key generated from acf plugin 'value' => 'Yes' ) ); $onepage = new WP_Query($args); ?> <?php if ( $onepage->have_posts() ) : while ( $onepage->have_posts() ) : $onepage->the_post(); ?> <div class="section"> <?php get_template_part( 'content', 'page' ); ?> </div> <?php endwhile; endif; // end of the loop. ?>
Above I tried to get only those pages that set to Yes from custom field but it showing all pages. I want only those that set to "Yes" through custom field I asked the question about it so this is part II. Please help. Thanks.
Note: I used Advanced Custom Field for creating the field and the field type is "Select" with two option Yes and No.. Thanks Again..