1

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)

2
  • What's wrong with the code above? I mean can you specify what exactly doesn't work? Commented Jul 1, 2014 at 8:21
  • <?php elseif ( is_front_page() ) : ?> //check this in else if, it is enough to check if the current page is main page Commented Jul 1, 2014 at 8:25

1 Answer 1

2

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; ?>
Sign up to request clarification or add additional context in comments.

2 Comments

Perfect - thankyou. Any reason why it works with || ?
Always one condition will always be true. Either front page or home

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.