I’ve got this simple code, that creates breadcrumbs:
function the_breadcrumb() {
if (!is_home()) {
echo '<a href="';
echo get_option('home');
echo '">';
echo 'home';
echo " / ";
if (is_category() || is_single()) {
the_category(' / ');
if (is_single()) {
echo " / " . '<a href="#">' . get_the_title() . '</a>';
}
} elseif (is_page()) {
echo " / " . '<a href="#">' . get_the_title() . '</a>';
}
}
}
And this echoes out:
<p class="bread-crumbs">
<a href="http://fashion-detail.dev">home / </a>
<a href="http://fashion-detail.dev/?cat=4" title="View all posts in Fashion" rel="category">Fashion</a> /
<a href="http://fashion-detail.dev/?cat=16" title="View all posts in Top" rel="category">Top</a> /
<a href="#">This is in the fashion category.</a>
</p>
However, it do not want it to show the a href
tag that links to the top
category. Is there a way to include a str_replace, or just prevent the_category from calling top
(I still need the post, I just don’t want to link to top
in the breadcrumbs)?
the_category
echo
s content. You will not be able to use string manipulation. No strings arereturn
ed that you could manipulate. They are justecho
ed immediately.You could completely filter out a particular category, which seems to be an option, with this:
You’d use it like:
There is no easy way to keep the category and remove the link. You’d need some nasty regex on the
the_category
filter.