WordPress Glossary Plugin (CMTG) - Extras - Configuring Breadcrumbs


Configuring Breadcrumbs

Back to User Guides

Disclaimer: This section doesn't cover all of cases, so the knowledge presented here may not apply to your theme. The last section contains instruction what to do in such case.

Basics

Many themes have a breadcrumbs functionality which assist the main navigation of the site. Unfortunately it's not one of the core WordPress functions, so it means that in each theme it can work differently. 

There are also plugins that add different breadcrumbs functionalities. This is the main reason why many of our customers are asking for help to configure the way breadcrumbs work with the WordPress Glossary plugin.

Example

Breadcrumbs usually look similar to this:

Home → Category → Post Name

Breadcrumbs example - WordPress Internal Linking Plugin
Breadcrumbs example

Use Cases

Usually breadcrumbs are not very customizable (if at all), while many users expect to be able to change their behavior. Also in some themes the breadcrumbs do not support custom post types at all.

In case of our plugin the most often use cases are:

  • Need to remove the breadcrumbs completely on the Glossary Term Pages.
  • Need to add the Glossary Index Page in the trail.
  • Need to add the tag/category in the breadcrumb trail on the Glossary Term pages..
  • Need to change the plugin label in the breadcrumbs.
  • Breadcrumbs are not showing at all.

In most cases some form of code manipulation on the theme is required to achieve the expected result.


How To Find Breadcrumbs In Theme

The easiest way to find the breadcrumbs function is to ask the theme owner for the file and the function name.

Usually the functions responsible for the breadcrumbs will have the word "breadcrumbs" in it, so if you're familiar with the text editors, you can try to search for it in the theme files.


Code Examples

This section contains the code required to make changes in the breadcrumbs functionality in specific themes.

Of course there are hundreds of thousands of themes out there and each one can theoretically add it's own implementation of breadcrumbs, so it's impossible to support them all.

Enfold (Avia Breadcrumbs)

The breadcrumbs in the Enfold theme are based on a modified WooThemes breadcrumb code. This is a popular theme, and a popular implementation, so it's possible that you will have the same/similar code

if you've bought one of the most popular themes (Avada/Divi) etc.

The function is called avia_breadcrumbs() and it can be found in the class-breadcrumb.php file.

Thankfully this version is using a filter, so we can quite easily hook into it and add new things to the breadcrumb list.

/* Allow child themes/plugins to filter the trail array. */

$trail = apply_filters( 'avia_breadcrumbs_trail', $trail, $args );

Here's an example code which you can use if you'd like to add the Glossary Index Page to the listing (for users visiting Glossary Term Page):

add_filter('avia_breadcrumbs_trail', 'cminds_add_glossary_index_to_breadcrumbs', 10, 2);


function cminds_add_glossary_index_to_breadcrumbs($trail, $args) {

$post = $wp_query->get_queried_object();

$post_type = $post->post_type;

if ( 'glossary' === $post_type && class_exists( 'CMTT_Glossary_Index' ) ) {

$last_element = array_pop( $trail );

$glossaryPageId = CMTT_Glossary_Index::getGlossaryIndexPageId();

$glossaryPageLink = get_permalink( $glossaryPageId );

$trail[] = '<a href="' . $glossaryPageLink . '">' . get_the_title( $glossaryPageId ) . '</a>';

array_push( $trail, $last_element );

}

return $trail;

}

If you put this code into your theme's function.php file it will work if you have the WordPress Glossary plugin active.

Breadcrumb Trail by Justin Tadlock

Another popular code that theme developers include is Breadcrumb Trail, which source code is available here

The following filters can be used: 

breadcrumb_trail_labels -for adding glossary or term labels. 

breadcrumb_trail_post_taxonomy -for changing "post" or category to terms. 


I'm using another source for breadcrumbs, what can I do?

Since all the breadcrumbs systems are different, If you're not using Enfold, and you have an issue with the breadcrumbs, please do the following things:

  • Determine the name of the theme/plugin of the source of the breadcrumbs.
  • Determine your use-case (most likely one of the list of Use Cases from the point above).
  • Determine the name of the filter/hook allowing to modify the breadcrumbs (Easiest if you contact the developers of the breadcrumb source plugin/theme for help).
  • Write back to our support making sure to provide all of the information.

If you can do these steps it can save a lot of time required for a research before the development.

Based on this information we should be able to fairly quickly create the fragment of code required to make the fix.


More information about the WordPress Glossary Plugin

Other WordPress products can be found at CreativeMinds WordPress Store

Let us know how we can Improve this Product Documentation Page

To open a Support Ticket visit our support center
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.