Welcome, guest!

Feel free to read the blog, browse for themes, or join the club.

Filtering breadcrumb_trail the actual $trail

  1. Ok so the problem at hand is that I am trying to filter the way that the function breadcrumb_trail gets the home link...

    I know how to filter and add text or remove and also add shortcode but just can't get my head around this one

    I am already filtering the breadcrumb_trail to remove the Browse like so

    add_filter('breadcrumb_trail', 'creative_breadcrumb_trail');
    function creative_breadcrumb_trail($breadcrumb) {
    		$breadcrumb = str_replace('Browse:', '', $breadcrumb);
    		return $breadcrumb;
    }

    I would like to change
    Taken from around breadcrumb-trail.php line:67

    $trail[] = '<a href="' . get_bloginfo('url') . '" title="' . get_bloginfo( 'name' ) . '" rel="home" class="trail-begin">' . $show_home . '</a>';

    to

    $trail[] = '<a href="' . get_bloginfo('url', 'display') . '" title="' . get_bloginfo( 'name' ) . '" rel="home" class="trail-begin">' . $show_home . '</a>';

    something along the lines of

    add_filter('breadcrumb_trail', 'creative_breadcrumb_home_trail');
    function creative_breadcrumb_home_trail($trail) {
    		$trail = '<a href="'  . get_bloginfo('url', 'display') . '" title="' . get_bloginfo( 'name' ) . '" rel="home" class="trail-begin">' . $show_home . '</a>';
    		return $trail;
    }

    But obviously this does not work.....

    I have tried all sorts of gimmickry before posting here and wonder if anybody can help....

    and stop giggling :) You know who you r...

    Any help gratefully received as usual

  2. You must be a logged-in exclusive member to view this reply.

  3. perfect!!

    thank you once again for resolving my probs....

  4. Ok just one small problem, when filtering out the Browse as I already am with this

    add_filter('breadcrumb_trail', 'creative_breadcrumb_trail');
    function creative_breadcrumb_trail($breadcrumb) {
    		$breadcrumb = str_replace('Browse:', '', $breadcrumb);
    		return $breadcrumb;
    }

    It does not validate without errors I would like to try to do is to remove the empty <span class="breadcrumb-title"></span> which is left in the breadcrumb
    so in all of my wisdom I thought I would try and hack the two together (your code from here creative_breadcrumb_home_trail plus my one ....

    but can't just quite get my head around it

    function creative_breadcrumb_home_trail( $trail ) {
    
    	$trail = preg_replace( "/<span class=\"breadcrumb-title\">Browse:/</span>/<a href=\".*?\" (.*?) rel=\"home\"/", '<a href="' . get_bloginfo( 'url', 'display' ) . '" $1 rel="home"', $trail );
    
    	return $trail;
    }

    Is this possible? or would I do better to keep them separate and remove the browse and its span in another way?

  5. You must be a logged-in exclusive member to view this reply.

Reply

You must log in to post.

Limited Access

If you have an account, please take a moment to log in.

Non-exclusive members have limited access to the support forums.

To enjoy the full range of support, sign up for an exclusive membership in the theme club.

Support Forums

  • Bliss Theme (253 posts)
  • Hybrid Theme (21,735 posts)
  • Options Theme (10,356 posts)
  • Structure Theme (2,747 posts)
  • Outline Theme (36 posts)
  • Visionary Theme (767 posts)
  • bbPress Themes (305 posts)
  • WordPress Plugins (2,045 posts)
  • General Discussion (5,276 posts)