Community Forums › Forums › Archived Forums › Design Tips and Tricks › If conditional question
- This topic has 1 reply, 1 voice, and was last updated 7 years, 11 months ago by tmg12.
-
AuthorPosts
-
May 10, 2016 at 7:22 am #185351tmg12Member
Hi All,
I am trying to apply my grid loop universally (conditionally ) through my functions.php rather than having to input it on each CPT and Taxonomy archive.
The code works fine when outside of my if conditional, but when I wrap it in
if ( is_post_type_archive() ) {}
it doesn't run further nested IF inside of the main IF conditional.The code works fine outside of the IF conditional, showing the custom fields its meant to call, but when I put inside of the IF conditional the custom fields are not echo'd.
Anyone have ideas why the IF conditionals aren't working when place in
if ( is_post_type_archive() ) {}
.Cant seem to work this one out. Thanks for any light shed on this!
Code is below.
//Content box display if ( is_post_type_archive() ) { //Build box content add_action ('genesis_entry_content','tg_box_edits'); function tg_box_edits() { ?> <hr id="short-line" align="left" width="100"> <?php if(get_field('1_star')){ ?> <?php echo the_field('stars'); ?> <i class="fa fa-star" aria-hidden="true"></i> <?php } ?> <?php if(get_field('2_star')){ ?> <?php echo the_field('stars'); ?> <i class="fa fa-star" aria-hidden="true"></i> <i class="fa fa-star" aria-hidden="true"></i> <?php } ?> <?php if(get_field('3_star')){ ?> <?php echo the_field('stars'); ?> <i class="fa fa-star" aria-hidden="true"></i> <i class="fa fa-star" aria-hidden="true"></i> <i class="fa fa-star" aria-hidden="true"></i> <?php } ?> <?php if(get_field('4_star')){ ?> <?php echo the_field('stars'); ?> <i class="fa fa-star" aria-hidden="true"></i> <i class="fa fa-star" aria-hidden="true"></i> <i class="fa fa-star" aria-hidden="true"></i> <i class="fa fa-star" aria-hidden="true"></i> <?php } ?> <?php if(get_field('5_star')){ ?> <?php echo the_field('stars'); ?> <i class="fa fa-star" aria-hidden="true"></i> <i class="fa fa-star" aria-hidden="true"></i> <i class="fa fa-star" aria-hidden="true"></i> <i class="fa fa-star" aria-hidden="true"></i> <i class="fa fa-star" aria-hidden="true"></i> <?php } ?> <?php if(get_field('nights_from')){ ?><h3 id = "nights_from"><?php the_field('nights_from'); ?> nights from</h3><?php } ?> <?php if(get_field('price')){ ?><h3 id = "price_from">£<?php the_field('price'); ?></h3><?php } ?> <ul id = "featured_list"> <?php if(get_field('feature_1')){ ?><li> <?php echo get_field('feature_1'); ?> </li><?php } ?> <?php if(get_field('feature_2')){ ?><li> <?php echo get_field('feature_2'); ?> </li><?php } ?> <?php if(get_field('feature_3')){ ?><li> <?php echo get_field('feature_3'); ?> </li><?php } ?> <?php if(get_field('feature_4')){ ?><li> <?php echo get_field('feature_4'); ?> </li><?php } ?> <?php if(get_field('feature_5')){ ?><li> <?php echo get_field('feature_5'); ?> </li><?php } ?> </ul> <div class = "btn_container"> <a id = "button" href = "<?php the_permalink(); ?>"> More info </a> </div> <?php }
May 10, 2016 at 7:45 am #185352tmg12MemberFound the solution.
Just needed to hook in before the loop for it work.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.