0

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

2 Answers 2

1

You should use get_categories. It supports an exclude argument.

0

Change this

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

to this

if(is_single() && !is_attachment()) {
6
  • Thanks Rarst of the answer, but I meant a specific category (eg, 3 or 4) .....
    – Branko
    Apr 3, 2011 at 6:49
  • @Fask then I am not sure, could you please clarify that? What exactly you want or don't want to happen under which conditions?
    – Rarst
    Apr 3, 2011 at 10:42
  • hello I would like to exclude categories 3 and 4 from get_category_parents
    – Branko
    Apr 27, 2011 at 16:56
  • @Fask that function doesn't support any arguments to exclude stuff and is recursive on top... It might be easier to modify result with str_replace() or something.
    – Rarst
    Apr 27, 2011 at 18:10
  • the fact is I'm not an expert you can help me?
    – Branko
    Apr 27, 2011 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.