Breadcrumb NavXT Paths 1.7.0

Announcing the immediate availability of Breadcrumb NavXT Paths 1.7.0. This version introduces changes to how term archives to page mapping works.

Previously, when a term was mapped to a page, that page’s hierarchy would be used for the rest of the breadcrumb trail. In Breadcrumb NavXT Paths 1.7.0, a new behavior was introduced where the term’s hierarchy would be maintained and only individual breadcrumbs would be replaced with pages. Toggling between the old behavior and the new behavior is controlled through the “Term Archive to Page Mapping” setting in the Paths section of the Breadcrumb NavXT settings page.

Users with valid and activated license keys should receive an update notification within the WordPress dashboard and be able to use the update mechanism to update (just like with any plugin in the WordPress.org repository).

-John Havlik

Breadcrumb NavXT and bbPress Compatibility Revisited

Since the last time the topic of Breadcrumb NavXT and bbPress Compatibility was investigated, almost 6 years ago, a little has changed in how both plugins operate. In fact, due to a change in how bbPress operates internally, Breadcrumb NavXT now supports post type jumping.

What Works

Out-of-the-box, forums and topics should work well. However, the settings recommendations have changed since the last visit of this topic. The current settings recommendations are:

  • Forum Root Page and Topic Root Page – Set these to be equal and to whatever page you have set as ‘Forum Root’ under Settings > Forums.
  • Forum Archive Display – Unchecked
  • Forum Hierarchy Display – Checked
  • Forum Hierarchy – Post Parent
  • Topic Archive Display – Checked
  • Topic Hierarchy Display – Checked
  • Topic Hierarchy – Post Parent

What Doesn’t Work

Out-of-the-box, topic tag archives still won’t work as expected. Additionally, the search page, search results page, and user pages do not work. These all require custom, bbPress specific code.

The Solution

Recently, Breadcrumb NavXT bbPress Extensions was updated to include support for the search page, search results pages, and user pages (at least the landing page for user pages, the various sub-pages are not supported yet). This is in addition to fixing the how topic tag archives show up in the breadcrumb trail.

-John Havlik

Breadcrumb NavXT Paths 1.6.0

Announcing the immediate availability of Breadcrumb NavXT Paths 1.6.0. This version adds a new filter, a new function, and the ability to enable/disable the referrer influenced term selection feature from the settings page.

Users with valid and activated license keys should receive an update notification within the WordPress dashboard and be able to use the update mechanism to update (just like with any plugin in the WordPress.org repository).

-John Havlik

Showing Private Posts in the Breadcrumb Trail

In Breadcrumb NavXT 6.4.0 the default behavior of Breadcrumb NavXT was changed to automatically exclude private posts from the breadcrumb trail. As part of this change, a new filter bcn_show_post_private was introduced to allow control over what private posts are included in the breadcrumb trail.

Basic Usage – Including All Private Posts

The following code, when placed in a site specific plugin, will enable display of all private posts in the breadcrumb trail.

add_filter('bcn_show_post_private', 'my_bcn_show_post_private', 10, 2);
function my_bcn_show_post_private($show, $ID)
{
	return true;
}

Something More Advanced

Rather than display all private posts in the breadcrumb trail, prehaps it is appropriate to show private posts of a specific post type. For example, the below will include private posts of the type forum (e.g. from bbPress) in the breadcrumb trail, while private posts from other post types will remain excluded.

add_filter('bcn_show_post_private', 'my_bcn_show_post_private', 10, 2);
function my_bcn_show_post_private($show, $ID)
{
	$post = get_post($ID);
	if($post instanceof WP_Post and $post->post_type === 'forum')
	{
		$show = true;
	}
	return $show;
}

This is not the only way private posts can be selectively included. Some other possibilities include checking if the user is logged in, checking if the user has specific permissions, or specifically include posts based on the post ID.

-John Havlik

Non-Hierarchical Taxonomies and JSON-LD Compatibility

While Breadcrumb NavXT for some time has provided methods for generating JSON-LD formatted BreadcrumbLists, the use of non-hierarchical taxonomies within a breadcrumb trail may result in non-compliant breadcrumb trails. For the case of a post only being a member of a single term within a non-hierarchical taxonomy, since Breadcrumb NavXT 6.4, compliant JSON-LD is generated. However, when a post is a member of multiple non-hierarchical terms within the same taxonomy, we run into problems.

When using the normal display functions, all of the terms in the non-hierarchical taxonomy that the post is a member of will be displayed, separated by commas. This behavior has been more-or-less the same since support for tags was added in 2.1.0. In essence, when there are multiple terms, there is a second dimension to the breadcrumb trail for that specific breadcrumb.

Unfortunately, it does not appear that Schema.org BreadcrumbList has the facility to support multi-dimensional breadcrumbs. Hence, a single term needs to be selected when there are multiple for a post. Luckily, the bcn_post_terms filter can be used to do this.

The Code

Introduced in Breadcrumb NavXT 5.4, bcn_post_terms allows us to filter out all of the terms returned by post_terms(). In this case, only the first term is wanted.

add_filter('bcn_post_terms','my_bcn_post_term_selector', 10, 3);
function my_bcn_post_term_selector($terms, $taxonomy, $id)
{
	//Check to ensure the terms list is an array and there is more than one item in it
	if(is_array($terms) and count($terms) > 1)
	{
		//Return the fist item in a new array
		return array(0 => reset($terms));
	}
	return $terms;
}

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

Note: This code relies on behavior introduced in Breadcrumb NavXT 6.4 and will not work in prior versions.

-John Havlik