Breadcrumb NavXT - Changes to Support invisible Categories

For a client I am using WordPress with Pages that Have sub-pages. On one of the sub-pages I need a list of employees. Each of these employees needs a bio page. Company Human Resources Betty Sue Luke Grant Engineering Sam Smaulson Grace Gelblum Clearly it makes the most amount of sense to have the staff pages be posts. And I could do all this as categories, but then I can write fun stuff on the Human Resources page like numbers to call, and such. So, I used pages for all but the individule staff pages.

I then grabbed the wonderful List category posts by Fernando Briano. I created a Category called Company and two sub-categories to “Company” called “Human Resources” (human-resources) and “Engineering”. Using List Category Posts I simply put catlist name=’company/human-resources’ on the “Human Resources” page. Then I go and make posts for Betty Sue and Luke Grant and make sure they have the category of “Human Resources”.

Now the bread crumb. You see, though Breadcrumb NavXT by John Havlik is fantastic it dose create links to categories for posts. But I want the breadcrumb links to take the user back to the pages. So I hacked his code to remove the extra “category/” link fragment. For my instilation of WordPress I am using “category” as my category prefix. So, if you go to http://mysite.com/category/company you get an archive list of all the posts that are assigned to the company category or any sub-categories. Because I have named my pages the same as my categories, I can yank the “category/” part of the url out of the breadcrumb and get links that go to my pages. And I think this will even work for my client.

So, in “breadcrumb_navxt_class.php” you will find two calls to get_term_link($term,$term->taxonomy) and two calls to get_term_link($term,$term->taxonomy). You simply need to change that code fragment to str_replace("category/", "", get_term_link($term, $taxonomy)) and str_replace("category/", "", get_term_link($term, $term->$taxonomy)) respectivly. This is kinda a hack, but it works.

get_term_link($term,$term->taxonomy)
becomes
str_replace("category/", "", get_term_link($term, $taxonomy))
and
get_term_link($term,$term->taxonomy)
becomes
str_replace("category/", "", get_term_link($term, $term->$taxonomy))

And, if you are using a different Category prefix, then fill that in instead of category/