将类别排除在“the_badcrumb”函数之外

时间:2011-04-01 作者:Fask

(对不起,我的英语)在我的主题中,我的面包屑功能。我想排除类别,你能帮我吗?代码如下:

    function the_breadcrumb() {
    global $post;
if (!is_home()) {
    echo \'<a href="\'.get_option(\'home\').\'">\'.home.\'</a>\';
    if (is_category()) {
        echo " / ";
        echo single_cat_title();
    } elseif(is_single() && !is_attachment()) {
        $cat = get_the_category(); $cat = $cat[0];
        echo " / ";
        echo get_category_parents($cat, TRUE, \' \' . $delimiter . \' \');
        echo " / ";
        echo the_title_shorten(45,\'...\');
    }       
    elseif (is_search()) {
        echo " / " . cerca;
    }       
    elseif (is_page() && $post->post_parent) {
        echo \' / <a href="\'.get_permalink($post->post_parent).\'">\';
        echo get_the_title($post->post_parent);
        echo "</a> / ";
        echo the_title_shorten(45,\'...\');       
    }
    elseif (is_page() OR is_attachment()) {
        echo " / "; 
        echo the_title_shorten(45,\'...\');
    }
    elseif (is_author()) {
        echo wp_title(\' / Profilo\');
        echo "";
    }
    elseif (is_404()) {
        echo " / "; 
        echo errore_404;
    }       
    elseif (is_archive()) {
        echo wp_title(\' / \');       
    }
        }
            }

2 个回复
SO网友:Matthew Muro

您应该使用get_categories. 它支持exclude参数。

SO网友:Rarst

更改此

if (is_category()) {
    echo " / ";
    echo single_cat_title();
} elseif(is_single() && !is_attachment()) {
到这个

if(is_single() && !is_attachment()) {

结束