Skip to main content
added 146 characters in body
Source Link
Hardeep Asrani
  • 692
  • 2
  • 10
  • 24

I added breadcrumb navigation to WordPress & I'm facing one problem. Here's the function.php code of the breadcrumb:

function ux_breadcrumbs() {
    if (!is_home()) {
        echo '<a href="';
        echo get_option('home');
        echo '">';
        bloginfo('name');
        echo "</a> » ";
        if (is_category() || is_single()) {
            the_category('/');
            echo " » ";
            if (is_single()) {
                echo "  ";
                the_title();
            }
        } elseif (is_page()) {
            echo the_title();
        }
    }
}

The above code is displaying all categories of the post. I just want it to display only one category. Thanks in advance!

UPDATE: Thanks for the help...here's one more thing:

I want to know how to display category > sub category in the breadcrumb if exists.

I added breadcrumb navigation to WordPress & I'm facing one problem. Here's the function.php code of the breadcrumb:

function ux_breadcrumbs() {
    if (!is_home()) {
        echo '<a href="';
        echo get_option('home');
        echo '">';
        bloginfo('name');
        echo "</a> » ";
        if (is_category() || is_single()) {
            the_category('/');
            echo " » ";
            if (is_single()) {
                echo "  ";
                the_title();
            }
        } elseif (is_page()) {
            echo the_title();
        }
    }
}

The above code is displaying all categories of the post. I just want it to display only one category. Thanks in advance!

I added breadcrumb navigation to WordPress & I'm facing one problem. Here's the function.php code of the breadcrumb:

function ux_breadcrumbs() {
    if (!is_home()) {
        echo '<a href="';
        echo get_option('home');
        echo '">';
        bloginfo('name');
        echo "</a> » ";
        if (is_category() || is_single()) {
            the_category('/');
            echo " » ";
            if (is_single()) {
                echo "  ";
                the_title();
            }
        } elseif (is_page()) {
            echo the_title();
        }
    }
}

The above code is displaying all categories of the post. I just want it to display only one category. Thanks in advance!

UPDATE: Thanks for the help...here's one more thing:

I want to know how to display category > sub category in the breadcrumb if exists.

Tweeted twitter.com/#!/StackWordPress/status/422845952853307392
Source Link
Hardeep Asrani
  • 692
  • 2
  • 10
  • 24

How to show only one category in breadcrumb navigation

I added breadcrumb navigation to WordPress & I'm facing one problem. Here's the function.php code of the breadcrumb:

function ux_breadcrumbs() {
    if (!is_home()) {
        echo '<a href="';
        echo get_option('home');
        echo '">';
        bloginfo('name');
        echo "</a> » ";
        if (is_category() || is_single()) {
            the_category('/');
            echo " » ";
            if (is_single()) {
                echo "  ";
                the_title();
            }
        } elseif (is_page()) {
            echo the_title();
        }
    }
}

The above code is displaying all categories of the post. I just want it to display only one category. Thanks in advance!