WordPress IF ELSEIF and ELSE Statement

Can someone explain why this does not work?

<?php if( !is_home() && !is_front_page() && !is_page( 105 )  ) : ?>
        <div class="col col-1">
            <div class="aside-form">
                <h3>Unlock your ideas</h3>

                    <?php echo do_shortcode("[si-contact-form form='1']"); ?>

            </div>
            <div class="aside-call">
                <span>or call us today on</span>
                <a href="tel:0892442833">9244 2833</a>
            </div>
        </div>
        <?php elseif ( is_home() && is_front_page() ) : ?>
                No Side Bar
        <?php else : ?>
        <div class="col col-1">
            <div class="aside-form">
                Different Side Bar
            </div>
        </div>
        <?php endif; ?>

Basically if not the home page or a page with ID 105 show the contact form, else if it is the home page show ‘no side bar’ else for everything else show ‘different side bar’ – it doesnt work as the home page still shows the ‘different side bar’ (and doesnt show the contact form either – which is correct)

Related posts

Leave a Reply

1 comment

  1. Try below. Note elseif ( is_home() || is_front_page() ) : :-

    <?php if( !is_home() && !is_front_page() && !is_page( 105 )  ) : ?>
            <div class="col col-1">
                <div class="aside-form">
                    <h3>Unlock your ideas</h3>
    
                        <?php echo do_shortcode("[si-contact-form form='1']"); ?>
    
                </div>
                <div class="aside-call">
                    <span>or call us today on</span>
                    <a href="tel:0892442833">9244 2833</a>
                </div>
            </div>
            <?php elseif ( is_home() || is_front_page() ) : ?>
                    No Side Bar
            <?php else : ?>
            <div class="col col-1">
                <div class="aside-form">
                    Different Side Bar
                </div>
            </div>
            <?php endif; ?>