WordPress.org

Ready to get started?Download WordPress

Forums

breadcrumbs for tags? (4 posts)

  1. sepp88
    Member
    Posted 3 years ago #

    hey guys, i'm using the following code to have breadcrumbs on my website. however i wonder how i can view a breadcrumb for a tag as well. now it only is shown for single-pages and categories but not for tags.

    if (!is_home()) {
    		echo " » ";
    		if (is_category() || is_single()) {
    			the_category('title_li=');
    			if (is_single()) {
    				echo " » ";
    				the_title();
    			}
    		} elseif (is_page()) {
    			echo the_title();
    		}
    	}

    thank you for your help!

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Try:

    elseif( is_tag() ) {
    	global $wp_query;
    	$tag = get_term( $wp_query->queried_object_id, 'post_tag');
    	echo $tag->name;
    }
  3. sepp88
    Member
    Posted 3 years ago #

    thank you! that worked perfectly!

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    Glad to have helped.

Topic Closed

This topic has been closed to new replies.

About this Topic