Support » Fixing WordPress » conditional statement – I keep breaking my site

  • Resolved csleh

    (@csleh)


    Can you help me make this conditional, so it doesn’t show on the home page?

    <p class=”breadcrumbs”>’
    <?php if ( function_exists( ‘breadcrumb_trail’ ) ) {
    breadcrumb_trail( array( ‘separator’ => ‘»’ , ‘before’ => ”,’show_home’ => __(‘home’, ‘breadcrumb_trail’) ) );
    }
    ?>
    </p>

    I keep trying but break the site.

Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi

    (@esmi)

    Forum Moderator

    Where does the function breadcrumb_trail() come from? Are you using a breadcrumb plugin? Or did you write this function?

    You’re right — I’ve been trying so many things I forget what’s been done. This is the Breadcrumb Trail plugin by Justin Tadlock. It’s customized to show &raquo between links, and to show “home” with a lowercase h to match the rest. There isn’t an option for skipping the home page.

    I tried wrapping it in variations of this:

    <?php
    if ( is_page('home')) {
    echo '';
    } else
    echo '<p class="breadcrumbs">'
    <?php if ( function_exists( 'breadcrumb_trail' ) ) {
    breadcrumb_trail( array( 'separator' => '»' , 'before' => '','show_home' => __('home', 'breadcrumb_trail') ) );
    }
    ?>
    echo '</p>';
    }
    ?>

    But it didn’t work.

    Since I’m calling a unique body id for each page, I’ll just set up css to display:none on this <p>.
    Should have thought of that earlier! Silly sleepy brain.

    Might what was i trying would work if I knew programming? Or because this is an “if” statement it wouldn’t combine with another “if” statement?

    esmi

    (@esmi)

    Forum Moderator

    You can combine ‘if statements’. So you could have something like:

    <?php if (function_exists( ‘breadcrumb_trail’ ) && !is_home() ) {
    breadcrumb_trail( array( ‘separator’ => ‘»’ , ‘before’ => ”,’show_home’ => __(‘home’, ‘breadcrumb_trail’) ) );
    }

    if you didn’t want it to show on the home page, for example.

    cool! I’m going to need to learn php. To my untrained eye it looks like the & ! makes an “and” statement become a ” is not” statement

    esmi

    (@esmi)

    Forum Moderator

    ! = “is not”
    && = “and”
    || = “or”

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘conditional statement – I keep breaking my site’ is closed to new replies.