Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

jawanet on "Please Fix breadcrumb Not show on page and category"

$
0
0

Hello all master wordpress.

I had a little problem with the coding breadcrumb.
breadcrumb does not appear on the title page view:
http://www.jawanet.com/hosting/

In category also does not appear:
http://www.jawanet.com/category/wordpress-tutorial/

And in the category of post types breadcrumb links nor can:
http://www.jawanet.com/review/brand/lenovo/

Please help the master of all that which I purpose to work.
This my code:

function jseo_breadcrumb() {

	/* === OPTIONS === */
	$text['category'] = 'Archive by Category "%s"'; // text for a category page
	$text['search']   = 'Search Result For <h1>%s</h1>'; // text for a search results page
	$text['tag']      = 'Posts Tagged "%s"'; // text for a tag page
	$text['author']   = 'Articles Posted by %s'; // text for an author page
	$text['404']      = 'Error 404'; // text for the 404 page

	$show_current   = 1; // 1 - show current post/page/category title in breadcrumbs, 0 - don't show
	$show_title     = 1; // 1 - show the title for the links, 0 - don't show
	$delimiter      = '<span style="padding: 0px 1px 0px 1px;"> » </span>'; // delimiter between crumbs
	$before         = '<span class="current">'; // tag before the current crumb
	$after          = '</span>'; // tag after the current crumb

	/* === END OF OPTIONS === */

	if (!is_home() && !is_front_page()) {
    global $post;
    $homelink = home_url() ;

/******  Please do not edit :P ********/

	$div_before   = '<div class="breadcrumb-list" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">';
	$div_after    = '</div>';
	$span_before_microdata = '<span itemprop="title" class="current">';
	$link_before  = '<span class="current">';
	$link_after   = '</span>';
	$link_attr    = ' itemprop="url"';
	$link         = $link_before . '<a' . $link_attr . ' href="%1$s">%2$s</a>' . $link_after;
	$parent_id    = $parent_id_2 = $post->post_parent;

    echo '<div class="breadcrumb"><div class="breadcrumb-wrap">';
        echo '<div class="breadcrumb-list"><a href="';
        echo home_url();
        echo '"><span>';
        echo 'Home</span>';
        echo '</a></div> ' . $delimiter . ' ';

    if (is_category() || is_single() || get_post_type() != 'post' ) {
        $post_type = get_post_type_object(get_post_type());
        $separator = ' ';
        $output = '';

    if($categories){
         $thisCat = get_category(get_query_var('cat'), false);
    if ($thisCat->parent != 0)
	    echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' ');
        echo $before . '' . single_cat_title('', false) . '' . $after;

    }
    if (is_single() && !is_attachment() ) {
		if ( get_post_type() != 'post' ) {

		$post_type = get_post_type_object(get_post_type());
		$slug = $post_type->rewrite;
		echo '<div class="breadcrumb-list" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
			  <a itemprop="url" href="' . $homeLink . '/' . $slug['slug'] . '/"><span itemprop="title">' . $post_type->labels->name . '
			  </span></a></div> ' . $delimiter . '';

	  if ($terms = get_the_terms( $post->ID , 'brand' )){
      foreach ( $terms as $term ) {
      $term_link = get_term_link( $term, 'brand' );
        echo '<div class="breadcrumb-list" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
				      <a itemprop="url" href="'.$term_link.'">
					  <span itemprop="title">' . $term->name . '</span></a></div> ' . $delimiter . ' ';
       }
    }
		echo $before . get_the_title() . $after;

	} else {
        $cat = get_the_category(); $cat = $cat[0];
        $cats = get_category_parents($cat, TRUE, $delimiter);

	  if ($show_current == 0) $cats = preg_replace("#^(.+)$delimiter$#", "$1", $cats);

			$cats = str_replace('<a', $div_before . '<a' . $link_attr, $cats);
            $cats = str_replace('</a>', '</a>' . $div_after, $cats);

			$cats = str_replace('<a', $span_before_microdata . '<a', $cats);
			$cats = str_replace('</a>', $span_after . '</a>', $cats);

      if ($show_title == 0) $cats = preg_replace('/ title="(.*?)"/', '', $cats);
        echo $cats;
      if ($show_current == 1) echo $before . get_the_title() . $after;
		}

	}
		else
		if ( !is_single() && !is_page() && get_post_type() !== 'post' && !is_search() && !is_paged()) {
			$post_type = get_post_type_object(get_post_type());
		if (!empty($post)) {
			echo $before . $post_type->labels->singular_name . $after;
			}
		else
			echo $before . __('No Results', 'comicpress') . $after;
       }
    }
    elseif ( is_attachment() ) {
      $parent = get_post($post->post_parent);
      $cat = get_the_category($parent->ID); $cat = $cat[0];
      echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
      echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>';
      if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;

    }
	elseif ( is_page() && !$post->post_parent ) {
      if ($showCurrent == 1) echo $before . get_the_title() . $after;

    } elseif ( is_page() && $post->post_parent ) {
      $parent_id  = $post->post_parent;
      $breadcrumbs = array();
      while ($parent_id) {
        $page = get_page($parent_id);
        $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
        $parent_id  = $page->post_parent;
      }
      $breadcrumbs = array_reverse($breadcrumbs);
      for ($i = 0; $i < count($breadcrumbs); $i++) {
        echo $breadcrumbs[$i];
        if ($i != count($breadcrumbs)-1) echo ' ' . $delimiter . ' ';
      }
      if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;

    }

        else
		 if ( is_search() ) {
			echo $before . sprintf($text['search'], get_search_query()) . $after;
	}
		if ( get_query_var('paged') ) {
			if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
			echo __('Page', 'jseo') . ' ' . get_query_var('paged');
			if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
		}
		echo '</div></div>';
        }
    }

All appear custom Post

Tanks in advance


Viewing all articles
Browse latest Browse all 8245

Trending Articles