• Resolved batters22

    (@batters22)


    I am using this plugin for a client’s site.

    The site uses a custom taxonomy (classification) with three levels, and a custom post type. Plugin works fine, but for some posts, the lowest taxonomy level is excluded from the breadcrumbs. This happens consistently by taxonomy – ie always works for a given taxonomy or always fails.

    Example which works: Classification for post:
    Industrial, Agricultural, Cultural, Military > Granite > Gate Posts
    Breadcrumb trail includes ‘Gate Posts’
    Link

    Example which works: Classification set for post:
    Industrial, Agricultural, Cultural, Military > Granite > Millstones
    Breadcrumb trail does not includes ‘Millstones’
    Link

    There are multiple examples with different classification set, and if I create a test post and change the classifications between the above examples, it always works with the first classification and always fails with the second.

    Any thoughts on why this might be occurring? There is no discernible pattern to the failures that I can see.

    https://www.ads-software.com/plugins/breadcrumb-navxt/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author John Havlik

    (@mtekk)

    Most likely, the cause is in the case of your second example, “Test Fail” is an explicit member of both “Granite” and “Millstones”. In WordPress, you only need it to be an explicit member of “Millstones” as it will be an implicit member of all parent terms. Breadcrumb NavXT will pick the first term hierarchy it finds for the specified taxonomy type (set in the Breadcrumb NavXT settings page) for the post type. This does not guarantee that it will find the deepest hierarchy, but it is faster than trying to find the deepest hierarchy. And, it does explain what you are seeing, if my assumption is correct about “Test Fail” being an explicit member of both “Granite” and “Millstones”.

    Thread Starter batters22

    (@batters22)

    Thanks John
    That doesn’t quite work here as all levels of the taxonomy are used for various purposes.

    In case anyone else comes across the same thing I fixed the issue by amending class.bcn_breadcrumb_trail.php, function post_hierarchy(), changing this:

    //Now find which one has a parent, pick the first one that does
    					$bcn_use_term = key($bcn_object);
    					foreach($bcn_object as $key=>$object)
    					{
    						//We want the first term hiearchy
    						if($object->parent > 0)
    						{
    							$bcn_use_term = $key;
    							//We found our first term hiearchy, can exit loop now
    							break;
    						}
    					}

    to this

    //Now find which one has a parent, pick the lowest level
    					$bcn_use_term = key($bcn_object);
    
    					$sb_keys = array();
    					$sb_key_parents = array();
    
    					foreach($bcn_object as $key=>$object)
    					{
    						//We want the first term hiearchy
    						if($object->parent > 0)
    						{
    							$sb_keys[] = $key;//read terms with parents into an array
    							$sb_key_parents[] = $object->parent;//read the parent terms into an array
    							//$bcn_use_term = $key;
    							//We found our first term hiearchy, can exit loop now
    						}
    
    					}
    
    					$sb_low_class =  array_diff ($sb_keys,$sb_key_parents);//find the difference between the two arrays - which will be the lowest term
    					if($sb_low_class) $bcn_use_term = array_shift($low_class);//and use it
    Thread Starter batters22

    (@batters22)

    Marked as resolved

    Plugin Author John Havlik

    (@mtekk)

    That doesn’t quite work here as all levels of the taxonomy are used for various purposes.

    Could you please elaborate on this use case? I want to make sure I am not misunderstanding/missing something in regards to term hierarchy use cases.

    Thread Starter batters22

    (@batters22)

    The custom taxonomy here is used to classify objects on Ordnance Survey maps. I also have custom fields against the taxonomy which are used to display different symbols on the maps dependent on the taxonomy. There are a lot of objects which need to be displayed and I didn’t want to have to traverse up and down taxonomies for each object when they are rendered on a map, hence all taxonomy levels are set for each object.

    I had the same problem, thanks for the fix batters22!

    However there was one small typo in a variable name, on the last line of your code, that made it bug when I first tried it.

    This line is :
    if($sb_low_class) $bcn_use_term = array_shift($low_class);//and use it
    but should be :
    if($sb_low_class) $bcn_use_term = array_shift($sb_low_class);//and use it

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Missing breadcrumbs from (some) custom taxonomy items’ is closed to new replies.