How to Remove post_type From Breadcrumb NavXT URLs

Beginning with Breadcrumb NavXT 5.3.0, post type archive support was enhanced with the addition of the post_type query argument under various circumstances. Usually, this occurs when the post type is not the primary post type for the taxonomy (e.g. it is not the first post type in the object_type array for the taxonomy), or for date archives. While this is arguably the correct behavior, it is not right for every circumstance.

Breadcrumb NavXT 5.4.0 introduces a new filter, bcn_add_post_type_arg, which furnishes the ability to override the decision on when to include the post_type query argument. This article covers the basic usage of this filter, along with some hints for more advanced uses.

Basic Code

The most basic code, listed below, disables adding the post_type query argument for all resources.

add_filter('bcn_add_post_type_arg', 'my_add_post_type_arg_filt', 10, 3);
function my_add_post_type_arg_filt($add_query_arg, $type, $taxonomy)
{
	return false;
}

To get started quickly, just copy and paste the above code into a site specific plugin and start playing.

Hints for (More) Advanced Uses

From the basic code above, notice that there are three parameters passed into the filter. The first is the decision Breadcrumb NavXT was going to make in regards to adding the post_type query argument. The second is the name of the post type that is under consideration for addition to the URL. Lastly, the third parameter is the name of the taxonomy, if applicable, for the archive the URL points to. With this information, more complex filtering/decision making can be achieved.

For example, it is possible to enable the post_type query argument for only specific post types, or for specific taxonomy archives. Or, the post_type query argument can be enabled for all but a specific post type or taxonomy. All it takes is a little conditional logic that looks at the second and third parameters of the filter function.

-John Havlik

[end of transmission, stay tuned]

How to Implement Schema.org BreadcrumbList with Breadcrumb NavXT

Recently, Google began supporting the new Schema.org BreadcrumbList microformat. This happens to be slightly more verbose than the previous RDFa Breadcrumbs setup, but Google is much better at parsing this new format, and it is fully HTML5 compliant. While there is no ‘one click’ configuration for RDFa breadcrumbs within Breadcrumb NavXT, support for them is not too difficult to configure. Note, this guide depends on features made available in Breadcrumb NavXT 5.3.0 and will not work fully in previous versions.

Calling Code Modifications

To begin, the wrapping div for the calling code needs to have typeof="BreadcrumbList" vocab="https://schema.org/" added to it. If you are migrating from RDFa Breadcrumbs, this code replaces xmlns:v="http://rdf.data-vocabulary.org/#". Below is an example calling code block for users of the regular bcn_display(); function.


<div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">
    <?php if(function_exists('bcn_display')) { bcn_display(); }?>
</div>

Settings Modifications

In general, you need a

<span property="itemListElement" typeof="ListItem">

wrapping around every breadcrumb, and an inner element containing property="name" that directly wraps the page title, and property="item" typeof="WebPage" in the anchor if the breadcrumb contains a link. Lastly, each breadcrumb needs a (note that the %position% template tag is a new feature in Breadcrumb NavXT 5.3.0). For the most part this will result in two replacements need to be made to all of the breadcrumb templates. For the linked breadcrumb templates, replace:

<a title="Go to %title%." href="%link%">%htitle%</a>

or

<span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" title="Go to %title%." href="%link%" class="%type%">%htitle%</a></span>

with:

<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Go to %title%." href="%link%" class="%type%"><span property="name">%htitle%</span></a><meta property="position" content="%position%"></span>

Note the extra span containing the typeof declaration. This is necessary for Google to pick up on the breadcrumb objects (even though the tag is redundant as the property should work on the anchor).

For the unlinked breadcrumb templates, replace:

%htitle%

or

<span typeof="v:Breadcrumb"><span property="v:title">%htitle%</span></span>

with:

<span property="itemListElement" typeof="ListItem"><span property="name">%htitle%</span><meta property="position" content="%position%"></span>

To jumpstart this replacement process, you can import the following Breadcrumb NavXT settings XML file. Breadcrumb NavXT Schema.org BreadcrumbList settings file (Right click and select “Save As”).

Final Notes

After updating your settings, use Google’s Structured Data Testing Tool to verify that your BreadcrumbList is detected properly by Google.

-John Havlik

[end of transmission, stay tuned]

How to Remove Breadcrumb NavXT 5.0 Migration Compatibility Layer

From version 5.0 through 5.1.1, Breadcrumb NavXT included an extra plugin named “Breadcrumb NavXT 5.0 Migration Compatibility Layer”. The purpose of this plugin was to help overcome a bug in WordPress that causes plugin updates to break if the file containing the plugin header changes. Beginning in 5.2.0, Breadcrumb NavXT no longer includes the Breadcrumb NavXT 5.0 Migration Compatibility Layer.

If you still have the Breadcrumb NavXT 5.0 Migration Compatibility layer activated when upgrading to Breadcrumb NavXT 5.2.0 you may see the following PHP warning:

Warning: fopen(…/wp-content/plugins/breadcrumb-navxt/breadcrumb_navxt_admin.php): failed to open stream: No such file or directory in …/httpdocs/wp-includes/functions.php on line 4183
Warning: fread() expects parameter 1 to be resource, boolean given in …/httpdocs/wp-includes/functions.php on line 4186 Warning: fclose() expects parameter 1 to be resource, boolean in …/httpdocs/wp-includes/functions.php on line 4189

As long as Breadcrumb NavXT is activated, the warning message above can be ignored. It is only warning that the Breadcrumb NavXT 5.0 Migration Compatibility Layer was activated but is no longer available. If Breadcrumb NavXT is activated, then the Breadcrumb NavXT 5.0 Migration Compatibility Layer was not doing anything useful.

Migration Compatibility Layer Removal

Updating to Breadcrumb NavXT 5.2 should automatically remove the Breadcrumb NavXT 5.0 Migration Compatibility Layer. However, if you are on an earlier version, you may remove the Breadcrumb NavXT 5.0 Migration Compatibility Layer by performing the following, using a FTP client (or SSH/SCP client) navigate to your WordPress install’s plugins directory. Find the breadcrumb-navxt directory. Within the breadcrumb-navxt directory, there should be a file named breadcrumb_navxt_admin.php, delete this file.

-John Havlik

[end of transmission, stay tuned]

Trimming Breadcrumb Title Lengths With CSS

Update 2015/1/24: Added CSS for Schema.org BreadcrumbList format that Breadcrumb NavXT 5.3.0+ uses.

While Breadcrumb NavXT has a setting for specifying the maximum length of a breadcrumb title, this feature has shortcomings. Namely, it does not handle HTML elements gracefully. This has been looked into in the past and is not an easy thing to fix. Additionally, from a semantical point of view, the breadcrumb trail markup should never be truncated. Thus, it is recommended that you do not use the “Max Title Length” setting. In fact, this setting will be deprecated in Breadcrumb NavXT 5.2, and removed in 5.3.

CSS offers a better solution, which will not leave you with garbled and/or truncated HTML tags, should they exist in your tile. This guide will show a way of keeping your breadcrumbs to a reasonable length without using the “Max Title Length” setting.

Continue reading

Netgear AirCard 340u (aka AT&T Beam) on Linux

Lately, I’ve found attempting to do web development on a local environment without Internet access while travelling just doesn’t cut it anymore. This is especially true for long roadtrips. Rather than dealing with tethering or a mobile hotspot, I decided to spring for a Netgear AirCard 340u. For GSM networks in the US, it happens to be the best USB wireless broadband modem currently available. It supports everything from GPRS through LTE on what appears to be most of the bands AT&T and T-Mobile currently use (a true rarity, though I can not confirm support of LTE on band 2 (1900MHz PCS), I do get T-Mobile LTE in the Twin Cities).

Continue reading