WordPress.org

Forums

[resolved] breadcrumbs function not working. (7 posts)

  1. pdxDaniela
    Member
    Posted 1 year ago #

    Found this function online

    function the_breadcrumb() {
            echo '<ul id="breadcrumbs">';
        if (!is_home()) {
            echo '<li><a href="';
            echo get_option('home');
            echo '">';
            echo 'Home';
            echo "</a></li>";
            if (is_category() || is_single()) {
                echo '<li>';
                the_category(' </li><li> ');
                if (is_single()) {
                    echo "</li><li>";
                    the_title();
                    echo '</li>';
                }
            } elseif (is_page()) {
                echo '<li>';
                echo the_title();
                echo '</li>';
            }
        }
        elseif (is_tag()) {single_tag_title();}
        elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
        elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
        elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
        elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
        elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
        elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
        echo '</ul>';
    }

    and then i call it w/
    <?php the_breadcrumb(); ?>

    but I get this

    Parse error: syntax error, unexpected ''<ul id='' (T_CONSTANT_ENCAPSED_STRING) in C:\xampp\htdocs\wordpress\wp-content\themes\cdiDlm03\functions.php on line 163

    how do i go about fixing this?
    Thank you
    D

  2. graphical_force
    Member
    Posted 1 year ago #

    What is the actual line that is throwing the error? I'm guessing it's echo '<ul id="breadcrumbs">'; but just want to be sure.

  3. pdxDaniela
    Member
    Posted 1 year ago #

    Hey grphical. Actually I belive that is it.
    so while i'd be curious to find out a found a better function (seems to work so far) at http://gilbert.pellegrom.me/how-to-breadcrumbs-in-wordpress

  4. graphical_force
    Member
    Posted 1 year ago #

    I just tested the code on a fresh install of wp 3.6 and I have no issue with the code. My suspicion is that something else in your functions.php file might be effecting it but the code itself seems to be fine.

  5. pdxDaniela
    Member
    Posted 1 year ago #

    not sure then but the new function i posted the link to is working fine.
    only thing, it creates three links. the top one remains empty. As i put the get_breadcrumbs call only on the third level pages. so not sure how to populate the top link?
    any advice please?
    thx
    D

  6. pdxDaniela
    Member
    Posted 1 year ago #

    that is of course the home link. how can i put an image (mini logo mabye) there instead?

    echo '<li><a href="'. get_settings('home') .'">'. get_bloginfo('name') .'</a></li>';
    or if I delete this will it wipe out the entire function?

  7. pdxDaniela
    Member
    Posted 1 year ago #

    just answered my own question. Deleted
    echo '<li><a href="'. get_settings('home') .'">'. get_bloginfo('name') .'</a></li>';

    worked (hope it won't break anything later on)

Topic Closed

This topic has been closed to new replies.

About this Topic