categories - Exclude category to "the_breadcrumb" functions

admin2025-06-03  4

(sorry for my english) in my theme I Breadcrumbs function. I would like to exclude the categories, can you help me? here's the code:

    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(' / ');       
    }
        }
            }

(sorry for my english) in my theme I Breadcrumbs function. I would like to exclude the categories, can you help me? here's the code:

    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(' / ');       
    }
        }
            }
Share Improve this question edited Feb 8, 2019 at 23:55 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Apr 1, 2011 at 15:55 BrankoBranko 135 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

You should use get_categories. It supports an exclude argument.

Change this

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

to this

if(is_single() && !is_attachment()) {
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748929539a314907.html

最新回复(0)