• Resolved nebota

    (@nebota)


    Hello,

    I like your plugin.

    I have an issue with breadcrumbs.
    I can’t change the “Single Question” permalink to anything.

    I mean, I’m able to enter desired name but on the front side it will remain “Question” as part of breadcrumbs.

    My breadcrumbs will always look “Home|Question|question-title”.

    When I click on |Question| part of the breadcrumb it will take me to correct url (the value I entered in the “Single Question” field and than quickly change it to “Question List Page” link).
    This is really weird.

    Is there a way to fix this?

    http://wordpress.org/plugins/dw-question-answer/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author DesignWall

    (@designwall)

    Thanks for letting us know. Can you give me your live site link or whats name of your breadcrumb plugin what you are using?

    Thread Starter nebota

    (@nebota)

    Hi again,

    I don’t use any breadcrumbs plugin, I do use Circles premium theme.

    This would be the piece of code responsible for breadcrumbs:

    function ts_the_breadcrumbs() {
    
      /* === OPTIONS === */
      $text['home']     = __('Home','circles'); // text for the 'Home' link
      $text['category'] = __('Archive by Category "%s"','circles'); // text for a category page
      $text['search']   = __('Search Results for "%s" Query','circles'); // text for a search results page
      $text['tag']      = __('Posts Tagged "%s"','circles'); // text for a tag page
      $text['author']   = __('Posts by %s','circles'); // text for an author page
      $text['404']      = __('404 Page Not Found','circles'); // text for the 404 page
    
      $showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
      $showOnHome  = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
      $delimiter   = ' <span class="delimiter">|</span> '; // delimiter between crumbs
      $before      = '<span class="current">'; // tag before the current crumb
      $after       = '</span>'; // tag after the current crumb
      /* === END OF OPTIONS === */
    
      global $post;
      $homeLink = home_url() . '/';
      $linkBefore = '<span typeof="v:Breadcrumb">';
      $linkAfter = '</span>';
      $linkAttr = ' rel="v:url" property="v:title"';
      $link = $linkBefore . '<a' . $linkAttr . ' href="%1$s">%2$s</a>' . $linkAfter;
    
      if (is_home() || is_front_page()) {
    
        if ($showOnHome == 1) echo '<div id="crumbs"><a href="' . $homeLink . '">' . $text['home'] . '</a></div>';
    
      } else {
    
        echo '<div id="crumbs" xmlns:v="http://rdf.data-vocabulary.org/#">' . sprintf($link, $homeLink, $text['home']) . $delimiter;
    
    	if (function_exists('is_shop') && is_shop()) {
    		echo $before . __('Shop','circles') . $after;
    	} else if ( is_category() ) {
          $thisCat = get_category(get_query_var('cat'), false);
          if ($thisCat->parent != 0) {
            $cats = get_category_parents($thisCat->parent, TRUE, $delimiter);
            $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
            $cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
            echo $cats;
          }
          echo $before . sprintf($text['category'], single_cat_title('', false)) . $after;
    
        } elseif ( is_search() ) {
          echo $before . sprintf($text['search'], get_search_query()) . $after;
    
        } elseif ( is_day() ) {
          echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter;
          echo sprintf($link, get_month_link(get_the_time('Y'),get_the_time('m')), get_the_time('F')) . $delimiter;
          echo $before . get_the_time('d') . $after;
    
        } elseif ( is_month() ) {
          echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter;
          echo $before . get_the_time('F') . $after;
    
        } elseif ( is_year() ) {
          echo $before . get_the_time('Y') . $after;
    
        } elseif ( is_single() && !is_attachment() ) {
          if ( get_post_type() != 'post' ) {
            $post_type = get_post_type_object(get_post_type());
    
    		if ($post_type -> query_var == 'product') {
    			$label = __('Shop','circles');
    		} else {
    			$label = $post_type->labels->singular_name;
    		}
    		$slug = $post_type->rewrite;
    
    		$portfolio_page_id = null;
    		if (get_post_type() == 'portfolio') {
    			$portfolio_page_id = ot_get_option('portfolio_page');
    		}
    		if (!empty($portfolio_page_id)) {
    			echo '<a href="'.get_permalink($portfolio_page_id).'">'.get_the_title($portfolio_page_id).'</a>';
    		} else {
    			printf($link, get_post_type_archive_link( $post_type -> name ), $label);
    		}
            if ($showCurrent == 1) echo $delimiter . $before . get_the_title() . $after;
          } else {
            $cat = get_the_category(); $cat = $cat[0];
            $cats = get_category_parents($cat, TRUE, $delimiter);
            if ($showCurrent == 0) $cats = preg_replace("#^(.+)$delimiter$#", "$1", $cats);
            $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
            $cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
            echo $cats;
            if ($showCurrent == 1) echo $before . get_the_title() . $after;
          }
    
        } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
          $post_type = get_post_type_object(get_post_type());
          echo $before . $post_type->labels->singular_name . $after;
    
        } elseif ( is_attachment() ) {
          $parent = get_post($post->post_parent);
          $cat = get_the_category($parent->ID); $cat = $cat[0];
          $cats = get_category_parents($cat, TRUE, $delimiter);
    	  if (!is_wp_error($cats))
    	  {
    		$cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
    		$cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
    		echo $cats;
    		printf($link, get_permalink($parent), $parent->post_title);
    	  }
          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[] = sprintf($link, get_permalink($page->ID), get_the_title($page->ID));
            $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;
    
        } elseif ( is_tag() ) {
          echo $before . sprintf($text['tag'], single_tag_title('', false)) . $after;
    
        } elseif ( is_author() ) {
           global $author;
          $userdata = get_userdata($author);
          echo $before . sprintf($text['author'], $userdata->display_name) . $after;
    
        } elseif ( is_404() ) {
          echo $before . $text['404'] . $after;
        }
        echo '</div>';
    
      }
    }

    And this would be the code for fetching displaying breadcrumbs as part of the header:

    if ($no_titlebar === false && is_page_template('template-contact-form-1.php')): ?>
    	<div class='wrapper headline relative <?php echo $page_path_class; ?>'>
    		<div class='bg-black-045'></div>
    		<div class='container relative'>
    			<div class='grid_12'>
    				<?php if ($show_title): ?>
    					<h1><?php echo $title; echo (!empty($subtitle) ? '<span> '.$subtitle.'</span>' : ''); ?></h1>
    				<?php endif; ?>
    				<?php if ($show_breadcrumbs && ot_get_option('show_breadcrumbs') != "no"): ?>
    					<div class='page-path'>
    						<?php ts_the_breadcrumbs();?>
    					</div>
    				<?php endif; ?>
    			</div>
    		</div>
    	</div>
    <?php elseif ($no_titlebar === false): 
    
    	$headlinge_class = '';
    	if (is_page() && !get_post_meta(get_the_ID(),'header_background',true) || !is_page() && !ot_get_option('default_title_background')) {
    		$headlinge_class = 'marble border-bottom-black-tr';
    	}
    	?>
    	<div class='wrapper headline <?php echo $page_path_class; ?> <?php echo $headlinge_class; ?>'>
    		<div class='container'>
    			<div class='grid_12'>
    				<?php if ($show_title): ?>
    					<h1><?php echo $title; echo (!empty($subtitle) ? '<span> '.$subtitle.'</span>' : ''); ?></h1>
    				<?php endif; ?>
    				<?php if ($show_breadcrumbs && ot_get_option('show_breadcrumbs') != "no"): ?>
    					<div class='page-path'>
    						<?php ts_the_breadcrumbs();?>
    					</div>
    				<?php endif; ?>
    			</div>
    		</div>
    	</div>
    <?php  endif; ?>

    If im asking too much by pasting this code, let me know.
    I would be very happy if would be able to point out the part of the code that may be causing the issues with pathing. I’m not expecting the solution, just to narrow down the possibilities.
    Thank you!

    Best regards,
    Neb

    Plugin Author DesignWall

    (@designwall)

    Hi Neb,
    Please go to the file “<Circles-theme-folder>/inc/template-tags.php”, line 749, replace :

    if (!empty($portfolio_page_id)) {
        echo '<a href="'.get_permalink($portfolio_page_id).'">'.get_the_title($portfolio_page_id).'</a>';
    } else {
        printf($link, get_post_type_archive_link( $post_type -> name ), $label);
    }

    by

    if ( get_post_type() == 'dwqa-question' ) {
        printf($link, get_post_type_archive_link( $post_type -> name ), 'Question List Page' );
    } else if (!empty($portfolio_page_id)) {
        echo '<a href="'.get_permalink($portfolio_page_id).'">'.get_the_title($portfolio_page_id).'</a>';
    } else {
        printf($link, get_post_type_archive_link( $post_type -> name ), $label);
    }

    Regards,

    Thread Starter nebota

    (@nebota)

    WOW!
    That worked like a charm.
    I’m amazed :))

    Thank you so much!
    Best regards,
    Nebo

    Hi, I have a very similar issue:

    function mm_breadcrumbs(){

    global $post;

    $breadcrumbs = ‘<ul class=”clearfix”>

    • ‘ . __( ‘Home’, THEME_SHORTNAME ) .’
    • <li class=”crumb-sep”>→’;
      if( is_attachment() ){
      $breadcrumbs .= ‘

    • <span>’ . get_the_title( $post->ID ) . ‘</span>
    • ‘;
      } elseif( is_author() ){
      $author = get_userdata( $post->post_author );
      $breadcrumbs .= ‘

    • <span>’ . __( ‘All post from ‘, THEME_SHORTNAME ) . $author->user_nicename . ‘</span>
    • ‘;
      } elseif( is_singular( ‘portfolio’ ) ){
      $taxonomy = get_the_terms( $post->ID, ‘portfolio_category’ );
      if( !empty( $taxonomy ) ){
      foreach( $taxonomy as $term ){
      $breadcrumbs .= ‘

    • slug, ‘portfolio_category’ ) . ‘”>’ . $term->name . ‘
    • ‘;
      $breadcrumbs .= ‘<li class=”crumb-sep”>→’;
      break;
      }
      }
      $breadcrumbs .= ‘

    • <span>’ . get_the_title( $post->ID ) . ‘</span>
    • ‘;
      } elseif( is_single() ){
      $category = get_the_category();
      $category = get_category_parents( $category[0]->cat_ID, true, ‘##’ );
      $category = explode( ‘##’, substr( $category, 0, strlen( $category )-2 ) );
      foreach( $category as $cat ){
      $breadcrumbs .= ‘

    • ‘ . $cat . ‘
    • ‘;
      $breadcrumbs .= ‘<li class=”crumb-sep”>→’;
      }
      $breadcrumbs .= ‘

    • <span>’ . get_the_title( $post->ID ) . ‘</span>
    • ‘;
      } elseif( is_page() ){
      $parent = $post->post_parent;
      $parents = array();
      while( $parent ){
      $page = get_page( $parent );
      $parents[] = ‘ID ) . ‘”>’ . get_the_title( $page->ID ) . ‘‘;
      $parent = $page->post_parent;
      }

      $parents = array_reverse( $parents );
      foreach( $parents as $page ){
      $breadcrumbs .= ‘

    • ‘ . $page . ‘
    • ‘;
      $breadcrumbs .= ‘<li class=”crumb-sep”>→’;
      }

      $breadcrumbs .= ‘

    • <span>’ . get_the_title( $post->ID ) . ‘</span>
    • ‘;
      } elseif( is_post_type_archive( ‘portfolio’ ) ){
      $breadcrumbs .= ‘

    • <span>’ . __( ‘All portfolio posts’, THEME_SHORTNAME ) . ‘</span>
    • ‘;
      } elseif( is_category() ){
      $breadcrumbs .= ‘

    • <span>’ . sprintf( __( ‘From the category archives "%s"’, THEME_SHORTNAME ), single_cat_title( ”, false ) ) . ‘</span>
    • ‘;
      } elseif( is_tag() ){
      $breadcrumbs .= ‘

    • <span>’ . sprintf( __( ‘From the tag archives "%s"’, THEME_SHORTNAME ), single_tag_title( ”, false ) ) . ‘</span>
    • ‘;
      } elseif( is_tax( ‘portfolio_category’ ) ){
      $breadcrumbs .= ‘

    • <span>’ . sprintf( __( ‘From the portfolio category archives "%s"’, THEME_SHORTNAME ), single_term_title( ”, false ) ) . ‘</span>
    • ‘;
      } elseif( is_day() ){
      $breadcrumbs .= ‘

    • <span>’ . sprintf( __( ‘From the daily archives "%s"’, THEME_SHORTNAME ), get_the_time( ‘F jS, Y’ ) ) . ‘</span>
    • ‘;
      } elseif( is_month() ){
      $breadcrumbs .= ‘

    • <span>’ . sprintf( __( ‘From the monthly archives "%s"’, THEME_SHORTNAME ), get_the_time( ‘F, Y’ ) ) . ‘</span>
    • ‘;
      } elseif( is_year() ){
      $breadcrumbs .= ‘

    • <span>’ . sprintf( __( ‘From the yearly archives "%s"’, THEME_SHORTNAME ), get_the_time( ‘Y’ ) ) . ‘</span>
    • ‘;
      } elseif( is_404() ){
      $breadcrumbs .= ‘

    • <span>’ . __( ‘Page not found’, THEME_SHORTNAME ) . ‘</span>
    • ‘;
      } elseif( is_search() ){
      $breadcrumbs .= ‘

    • <span>’ . sprintf( __( ‘You search for "%s"’, THEME_SHORTNAME ), get_search_query() ) . ‘</span>
    • ‘;
      }
      $breadcrumbs .= ”;

      echo apply_filters( ‘mm_breadcrumbs_output’, $breadcrumbs );

      }

      Notice: Undefined offset: 0 on
      $category = get_category_parents( $category[0]->cat_ID, true, ‘##’ );

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Breadcrumbs’ is closed to new replies.