WordPress.org

Ready to get started?Download WordPress

Forums

Breadcrumb NavXT
"Unpost_tag" crumb for Custom Post Types /w no Tags (5 posts)

  1. bytesmasher
    Member
    Posted 2 years ago #

    It seems if you're viewing a custom post type post that has no tags when tags are enabled for that CPT, "Unpost_tag" shows up as a crumb. Looking at the code, this seems to be a feature of some sort, but it's a horribly unwanted feature, and it would be nice if I could disable it without having to change the plugin code. In fact, the ability to remove tags entirely from the breadcumbs would be nice as well.

    http://wordpress.org/extend/plugins/breadcrumb-navxt/

  2. bytesmasher
    Member
    Posted 2 years ago #

    Updated post_terms function for breadcrumb_navxt_class.php for anyone else who's having this issue:

    function post_terms($id, $taxonomy)
    	{
    		/* How about instead of doing this here, we check first to see if there's tags, mmmkay?
    		//Add new breadcrumb to the trail
    		$this->trail[] = new bcn_breadcrumb();
    		//Figure out where we placed the crumb, make a nice pointer to it
    		$bcn_breadcrumb = &$this->trail[count($this->trail) - 1];
                    */
    		//Fills a temporary object with the terms for the post
    		$bcn_object = get_the_terms($id, $taxonomy);
    		//Only process if we have tags
    		if(is_array($bcn_object))
    		{
                            // Start Edit
    			  //Add new breadcrumb to the trail
    			  $this->trail[] = new bcn_breadcrumb();
    			  //Figure out where we placed the crumb, make a nice pointer to it
    			  $bcn_breadcrumb = &$this->trail[count($this->trail) - 1];
    		        // End edit
    			$is_first = true;
    			//Loop through all of the term results
    			foreach($bcn_object as $term)
    			{
    				//Run through a filter for good measure
    				$term->name = apply_filters("get_$taxonomy", $term->name);
    				//Everything but the first term needs a comma separator
    				if($is_first == false)
    				{
    					$bcn_breadcrumb->set_title($bcn_breadcrumb->get_title() . ', ');
    				}
    				//This is a bit hackish, but it compiles the term anchor and appends it to the current breadcrumb title
    				$bcn_breadcrumb->set_title($bcn_breadcrumb->get_title() . str_replace(
    					array('%title%', '%link%', '%htitle%', '%type%'),
    					array($term->name, get_term_link($term, $taxonomy), $term->name, $term->taxonomy),
    					$this->opt['H' . $term->taxonomy . '_template']));
    				$is_first = false;
    			}
    		}
    		else
    		{
    			//If there are no tags, then we set the title to "Untagged" .... wait, why not just *not* display the crumb? WTF?
    		//	$bcn_breadcrumb->set_title(__('Un' . $taxonomy, 'breadcrumb_navxt'));
    		}
    	}
  3. John Havlik
    Member
    Plugin Author

    Posted 2 years ago #

    Well, it stems from when this code was extended from just supporting tags, to supporting all flat hiearchies (chenged the message from 'Untagged' to 'Un' + taxonomyname). Ofcourse, since I don't test every combination (especially things I do not use that require setting changes to test) I didn't catch that for post_tags it will look funky. The "Untagged" message is from way back when Breadcrumb NavXT 2.0 was written (a rewrite of Breadcrumb Navigation XT) and tag support was changed from Simple tags to WordPress' built-in tags. This should probably be changed to be more elegant (and not display silly things like 'Unpost_tag').

    Support for removing specific taxonomy terms is not on the current roadmap for Breadcrumb NavXT. Every case I have seen, thus far, for this is to have a hidden taxonomy term. With the advent of custom taxonomies, having a hidden taxonomy term is not a wise way of doing things (create a custom taxonomy for it, or use post_meta). Use a combination of categories, tags, and custom taxonomy types to achieve what you want to do, and select the most appropriate one (typically categories for Posts) as the taxonomy for Breadcrumb NavXT to listen to.

  4. bytesmasher
    Member
    Posted 2 years ago #

    I'm not using hidden taxonomy terms... I'm using custom post types. The issue arose because the post type has tags enabled, but there were no tags on the posts in question. I'd like the option to hot display tags in my breadcrumbs at all, as I'm going to be adding quite a lot of tags to my posts.

  5. John Havlik
    Member
    Plugin Author

    Posted 2 years ago #

    Well, then that isn't hiding specific tags/terms, if you want to use a different taxonomy for a post look for the Post Taxonomy option for that specific post type (each post type has it's own tab in the Breadcrumb NavXT settings page). If you do not want to have a taxonomy in the breadcrumb trail for a specific post type, uncheck the Post Taxonomy Display option.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic