WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] conditional statement - I keep breaking my site (6 posts)

  1. csleh
    Member
    Posted 5 years ago #

    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.

  2. esmi
    Forum Moderator
    Posted 5 years ago #

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

  3. csleh
    Member
    Posted 5 years ago #

    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?

  4. esmi
    Forum Moderator
    Posted 5 years ago #

    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.

  5. csleh
    Member
    Posted 5 years ago #

    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

  6. esmi
    Forum Moderator
    Posted 5 years ago #

    ! = "is not"
    && = "and"
    || = "or"

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.