Specifying a Preferred Category Hierarchy

As part of the best practises for organizing your WordPress site so that Breadcrumb NavXT’s output is what you expect, having a post be a member of multiple category hierarchies is something you should not do. While it still isn’t something you should do, there is a way to specify which category hierarchy is more important for a specific post.

The idea is that the order of the categories being returned by get_the_terms() can be modifed so that the more important category hierarchy is output first. This takes advantage of Breadcrumb NavXT’s behaviour of choosing the first category (term) hierarchy it finds for a post.

This is where Order Bender comes in. Order Bender gives you a nice post meta box to select the primary category for a post, and will modify the output order of get_the_terms() accordingly. Simple as that.

Installation is quite easy:

  1. Download the Master branch zip archive from GitHub
  2. In your WordPress Dashboard navigate to the plugin uploader (Plugins > Add New > Upload)
  3. Upload the zip archive
  4. Activate and enjoy!

You can keep up with day to day development via the Order Bender’s GitHub Repository.

-John Havlik

[end of transmission, stay tuned]

Setting a Parent for a Post

Normally, flat post types such as the Post post type do not have parents. However, some people like to use pages for their hierarchy and want posts to be children of these pages. Typically, these pages have a description and then a post list based off of a category.

While I personally do not recommend this type of site structure, Breadcrumb NavXT has supported Pages as the parent of Posts for quite some time. The caveat has always been that setting the parent of the post was an exercise left to the user. I’ve just written a fairly basic plugin that removes that makes things easier. All it does is add a Parent metabox with a pages drop down to the edit screen for posts.

Installation is quite easy:

  1. Download the Master branch zip archive from GitHub
  2. In your WordPress Dashboard navigate to the plugin uploader (Plugins > Add New > Upload)
  3. Upload the zip archive
  4. Activate and enjoy!

You can keep up with day to day development via the Post Parents’ GitHub Repository.

-John Havlik

[end of transmission, stay tuned]

Using Schema.org’s Breadcrumb Microdata with Breadcrumb NavXT

Note, that Schema.org breadcrumb has been replaced by the newer BreadcrumbList. Please see the How to Implement Schema.org BreadcrumbList with Breadcrumb NavXT article for more information.

Unlike Google’s Breadcrumb micodata format, Schema.org’s microdata format for breadcrumbs is very easy to implement. There is no need for nested tags, or overly verbose and redundant tags. Instead, there is just two modifications from the standard Breadcrumb NavXT setup.

Breadcrumbs are a property of the Schema.org WebPage CreativeWork type. The first thing you must do to use the Schema.org microdata is declare the body of the (x)HTML page to be of type WebPage. You’ll need to modify your current WordPress theme so that the opening body tag is:

<body itemscope itemtype="http://schema.org/WebPage">

Once we’ve declared our body to be of type WebPage, all we have to do is include itemprop=”breadcrumb” in the div wrapping around the breadcrumb trail. For example, we’d use:

<div itemprop="breadcrumb" class="breadcrumbs">
    <?php if(function_exists('bcn_display')) { bcn_display(); }?>
</div>

That’s it! Note that this does not work with the included widget in 4.0.1, and is something that will be changed for the next release.

-John Havlik

[end of transmission, stay tuned]

Use an Icon/Image for the Home Breadcrumb

This is a really easy one. However, as I’ve been asked about it several times in the past few weeks, I’m going to post about it.

One way of using an image rather than just text for the home breadcrumb was covered in the Vista-Like Breadcrumbs for WordPress article back in 2009. However, that guide is more or less an advanced topic, and directly accesses the bcn_breadcrumb_trail class, something that is currently not recommended.

Since at least Breadcrumb NavXT 3.0, the settings page allows you to use valid HTML in some fields. In the future this will be more obvious due to settings page tweaks as it is not exactly obvious that this is possible. There are really only three steps to changing from text to an image for the home breadcrumb:

  1. Go to the Breadcrumb NavXT settings page (under Settings > Breadcrumb NavXT).
  2. On the “General” tab, look for the “Home Template” option.
  3. Replace the text value of the “Home Template” option with the valid HTML for your image. e.g.
    <img src="http://YOUR_URL/YOUR_HOME_IMAGE" alt="Home"/> where YOUR_URL is the URL for your website, and YOUR_HOME_IMAGE is the name of the image, including file extension.

That’s it, and it also works for the “Blog Breadcrumb” and “Mainsite Breadcrumb” in setups that have these breadcrumb types.

-John Havlik

[end of transmission, stay tuned]

Conditionally Remove Home from the Breadcrumb Trail

Since Breadcrumb NavXT 3.5.0, two WordPress actions have been added into Breadcrumb NavXT. They are the bcn_before_fill and bcn_after_fill actions. As their names suggest, the first runs at the beginning of bcn_breadcrumb_trail::fill(), and the second runs at the end of the same function. Both actions pass a reference to the current bcn_breadcrumb_trail instance into the hooked function. This post quickly covers a use case for the bcn_after_fill action.

Continue reading