Remove the Link in a Breadcrumb

A topic that comes up time to time in support requests is how to unlink a breadcrumb. Typically this is due to having an empty page that exists to facilitate a logical hierarchy. Naturally, linking to this blank page in the breadcrumb trail is not useful. While it is bad form to have a breadcrumb in the breadcrumb trail that is not linked, there is a filter that can facilitate this behavior.

The presented solution is a simplistic example for a single page. However, it can be extended for multiple pages, or taxonomy terms. Finally, rather than being hard-coded, the IDs could come from a post_meta/term_meta field.

The Code (Breadcrumb NavXT 6.5)

Introduced in Breadcrumb NavXT 6.5, the bcn_breadcrumb_linked filter makes changing the linked status quite simple:

add_filter('bcn_breadcrumb_linked', 'my_breadcrumb_url_stripper', 3, 10);
function my_breadcrumb_url_stripper($linked, $type, $id)
{
	if(in_array('post-page', $type) && (int) $id === MYPAGEID)
	{
		return false;
	}
	return linked;
}

The Code (Pre-Breadcrumb NavXT 6.4)

Due to changes introduced in Breadcrumb NavXT 6.4, the below only works with versions of Breadcrumb NavXT prior to 6.4:

add_filter('bcn_breadcrumb_url', 'my_breadcrumb_url_stripper', 3, 10);
function my_breadcrumb_url_stripper($url, $type, $id)
{
	if(in_array('post-page', $type) && (int) $id === MYPAGEID)
	{
		$url = NULL;
	}
	return $url;
}

After placing this code into your site specific plugin, you will need to update one part of it. Just replace MYPAGEID with the ID of the page you want to remove the link to. That’s it. Simple, right?

-John Havlik

[end of transmission, stay tuned]

Link to a Page Rather Than the Category Archive in a Breadcrumb

A topic that frequently comes up in the support forums is how to have a breadcrumb representing a category link to a Page (instance of the Page post type) rather than a category archive. Since this is not natively supported by WordPress, Breadcrumb NavXT does not natively support it. However, there is a filter that can facilitate this behavior.

The presented solution is a simplistic example for a single category. However, it can be extended for multiple categories, or taxonomy terms. Finally, rather than being hard-coded, the IDs could come from a term_meta field.

The Code

add_filter('bcn_breadcrumb_url', 'my_breadcrumb_url_changer', 3, 10);
function my_breadcrumb_url_changer($url, $type, $id)
{
	if(in_array('category', $type) && (int) $id === MYCATID)
	{
		$url = get_permalink(PAGEID);
	}
	return $url;
}

After placing this code into your site specific plugin, you will need to update two portions of it. Replace MYCATID with the ID of the category you want to change the link on, and replace PAGEID with the page you wish for the breadcrumb to link to. That’s it. Simple, right?

-John Havlik

[end of transmission, stay tuned]

Working Around “[drm] stuck on render ring” on Intel GMA

After acquiring a Broadwell generation Core i3 NUC (the NUC5i3RYK to be exact) and installing Linux, KDE/X.Org would lockup and crash frequently. Checking dmesg, the following messages appeared:

[drm] stuck on render ring
[drm] GPU HANG:…

From the dmesg report, it is clear the crashes were caused by the GPU hanging. After further inspection of the dmesg logs, it appears this is due to a bug between Intel’s graphics and IOMMU drivers. The easiest way to work around this is to disable Intel IOMMU support.

Since I had compiled IOMMU support into my kernel, removing IOMMU support involved a kernel recompile. When configuring your kernel using menuconfig, make sure that “Support for Intel IOMMU using DMA Remapping Devices” under “Device Drivers > IOMMU Hardware Support” is unchecked. This is equivalent to ensuring that INTEL_MMU = n in your .config file. For the NUC, that was all that was required to keep the GPU driver from crashing and taking X.Org and KDE down with it.

-John Havlik

[end of transmission, stay tuned]

Add a Static Breadcrumb to the Breadcrumb Trail

In some cases WordPress may be not be running your entire site. In these instances, there may be a root above what WordPress knows about. To add a breadcrumb to represent this, you have two options.

  1. Breadcrumb NavXT Menu Magic can be used. You will need to have a ‘custom item’ menu entry that represents this off WordPress resource and is the root to all of the other menu entries.
  2. Write a little code in a site specific plugin.

The Code

The Menu Magic method is neat and does not require any code writing. However, that’s not what this article is really about. Besides, the required code is quite simple. The following code just needs to be placed in a site specific plugin (or your theme’s functions.php if that floats your boat):

add_action('bcn_after_fill', 'my_static_breadcrumb_adder');
function my_static_breadcrumb_adder($breadcrumb_trail)
{
    $breadcrumb_trail->add(new bcn_breadcrumb('STATIC_TITLE', NULL, array('home'), 'STATIC_URL', NULL, true));
}

After placing this code into your site specific plugin, you will need to update two portions of it. Replace STATIC_TITLE with the title of the resource this breadcrumb represents, and replace STATIC_URL with the URL to the resource represented by this breadcrumb. That’s it. Simple, right?

-John Havlik

[end of transmission, stay tuned]

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]