I added a true / false flag using additional custom fields for Wordpress. I want to be able to choose an option that modifies the page template.
I am adding this parameter to the product category in WooCommerce / Wordpress. I have included this bit of logic in the code.
I have the following code, but it does not work. I suspect this is because it is not in a loop. However, the code I want to insert includes a loop. Any ideas / recommendations on the code are greatly appreciated.
<?php if (is_product_category() && get_field('field_name') == true) { ?>
<div class="custom-sidebar-right">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php woocommerce_get_template_part( 'content', 'product' ); ?>
<?php endwhile;
</div>
<?php } elseif (is_product_category() && get_field('field_name') == false ) {
<div> Empty Test </div>
}
source
share