Support

Account

Home Forums Front-end Issues Using Checkbox conditional logic in a loop Reply To: Using Checkbox conditional logic in a loop

  • Fixed.
    I used true/false instead of checkbox field and used this code.

    $args = array(
                'post_type' => 'page',
                'meta_key' =>'featured_page',
                'meta_value'=>'1'
            );
    
                    // get results
                    $the_query = new WP_Query( $args );
    
                    // The Loop
                    ?>
                    <?php if( $the_query->have_posts() ): ?>
                        <ul>
                            <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
                                <li>
                                    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                                </li>
                            <?php endwhile; ?>
                        </ul>
                    <?php endif; ?>
    
                    <?php wp_reset_query(); ?>