mardi 3 janvier 2017

Nesting PHP using if statement

I have some PHP code

<div class="pod-b footer-pod">
            <h3 class="footer-title">Our Contacts</h3>
            <?php   
            $teachers = tribe_get_organizers_custom();  
            ?>

                <?php foreach ($teachers as $teacher){

                    // vars
                    $id = $teacher -> ID;
                    $title = $teacher -> post_title;
                    $yogaName = get_field('yoga_name', $id);
                    $phone = tribe_get_organizer_phone($id);
                    $email = tribe_get_organizer_email($id);
                ?>
                    <div class="teacher id_<?php echo $id; ?>">
                        <h4 class="teacher-name"><?php if($yogaName){echo $yogaName;}else{echo $title;}  ?></h4>
                        <div class="teacher-phone"><i class="ion-android-call"></i><?php echo $phone;  ?></div>
                        <div class="teacher-email"><i class="ion-ios-email"></i><a href="mailto:<?php echo $email;  ?>"><!--<?php echo $email;  ?>-->Email me</a></div> 
                    </div>

                <?php }?>
        </div>

That i want to wrap the div with class of "teacher (id)" in an if statement:

if (!get_field('hide_the_teacher_bio_on_this_event')) {

  • but am getting a little stuck on my syntax; where to add / remove the opening and closing PHP tags to my original block of code to get it to work.

Any help massivley appreciated! thanks

Aucun commentaire:

Enregistrer un commentaire