WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently I am working on adding a breadcrumb without a plugin to a site. I found several possibilities on how to do that, but what I specifically want is to take one Page out of the trail.

My current trail is as follows: home - products - productgroup - productsubgroup - productname

What I want it to become is: home - productgroup - productsubgroup - productname

Does anyone have experience with this particular challenge?

I'm on the latest WP version and I am using a child theme of Twenty Ten. More info on the breadcrumb I am using: http://www.bloggingtips.com/2009/02/22/create-a-breadcrumb-trail/

share|improve this question
up vote 1 down vote accepted

Based on the code your used my guess is it would be as simple as adding a unset($bcarray[0]); to their code on line 15. Here is the code in it's entirety:

function write_breadcrumb() {
  $pid = $post->ID;
  $trail = "<a href='/'>Home</a>";
  if (is_front_page()) :
    // do nothing
  elseif (is_page()) :
    $bcarray = array();
    $pdata = get_post($pid);
    $bcarray[] = " &raquo; ".$pdata->post_title."\n";
    while ($pdata->post_parent) :
      $pdata = get_post($pdata->post_parent);
      $bcarray[] = " &raquo; <a href='".get_permalink($pdata->ID)."'>".$pdata->post_title."</a>\n";
    $bcarray = array_reverse($bcarray);
    foreach ($bcarray AS $listitem) :
      $trail .= $listitem;
  elseif (is_single()) :
    $pdata = get_the_category($pid);
    $data = get_category_parents($pdata[0]->cat_ID, TRUE, ' &raquo; ');
    $trail .= " &raquo; ".substr($data,0,-8);
  return $trail;


share|improve this answer
Thanks Mike, for both the answer and the speed! What does the 0 mean in your additional line? update: it works brilliantly, thanks again! – Piet Dec 17 '10 at 10:25
@Piet: The [0] is the first element in the array named $bcarray which is also the last item added to the array which was the one you wanted removed. It's that's not clear, ask again. Thanks for the checkmark and upvote. – MikeSchinkel Dec 18 '10 at 9:29
ah ok, so if I would have liked to remove any other parent down the line, I could change that number? Thx for the additional explanation! It's easy to copy and paste and find out it works, it's better to fully understand what's happening and why :) – Piet Dec 22 '10 at 5:53
@Piet - Sure. If you really want to find out what works, get a copy of PhpStorm (while it's still $49) and get the debugger set up and then you can know all, just like me. :) – MikeSchinkel Dec 22 '10 at 6:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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