Viewing 8 replies - 1 through 8 (of 8 total)
  • Hamergil, found any solution? I have the same problem.

    Thread Starter hamergil

    (@hamergil)

    No
    I figured out another option
    I am just using 2 different breadcrumbs scripts
    and show them differently in each language using the languages if else statement technique:

    <?php if(ICL_LANGUAGE_CODE=='en'): ?>
    ////Show one breadcrumb
    <?php elseif(ICL_LANGUAGE_CODE=='it'): ?>
    ////Show another breadcrumb
    <?php endif; ?>

    I know it is not the best solution but it works pretty well.

    Hello hamergil, thanks to answer. I explain the solution I found at least. I uninstalled the plugin and did the work with a script in functions.php
    The script is a match from the boostrapwp build in and the code posted by Jonathan in this threat 3 months ago:
    https://www.ads-software.com/support/topic/help-fix-breadcrum-function-for-custom-post-types

    I’m still improving the code, but it is working, and it is not necessary to use a different script for every language. WPML translate correctly all the content because it is using the translated strings of every taxonomy and the __(‘home’) translation as well.

    Note that you have to change the “ctegori-producte’ string by whatever is your taxonomy. Note also that you can straight forward of this little code :

    $idlang = icl_object_id(42, 'page', false );
            permalinkk = get_permalink( $idlang );
    	echo '<li><a href="' . $permalinkk . '">' . get_the_title($idlang) . '</a></li> ' . $delimiter . ' ';

    where I put a reference to a ‘page’ that is the wrapper for all the categories that belongs to my custom post typ ‘producte’ that is the one the taxonomy ‘categoria-producte’ is associated, but no exists as a taxonomy. This is only for my purposes, but may be usefull also for someone more.
    Hope this help.

    function bootstrapwp_breadcrumbs() {
    
      $delimiter = '<span class="divider"> ? </span>';
      $home = __('home','bootstrapwp'); // text for the 'Home' link
      $before = '<li class="active">'; // tag before the current crumb
      $after = '</li>'; // tag after the current crumb
    
      if ( !is_home() && !is_front_page() || is_paged() ) {
    
        echo '<ul class="breadcrumb">';
    
        global $post;
        $homeLink = home_url();
        echo '<li><a href="' . $homeLink . '">' . $home . '</a></li> ' . $delimiter . ' ';
    
        if ( is_category() ) {
          global $wp_query;
          $cat_obj = $wp_query->get_queried_object();
          $thisCat = $cat_obj->term_id;
          $thisCat = get_category($thisCat);
          $parentCat = get_category($thisCat->parent);
          if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
          echo $before . 'Archive by category "' . single_cat_title('', false) . '"' . $after;
    	}
    	elseif ( is_tax('categoria-producte') ) {
    		global $wp_query;
    		echo $prepend;
    		$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    		$parents = array();
    		$parent = $term->parent;
    		while ( $parent ) {
    			$parents[] = $parent;
    			$new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) );
    			$parent = $new_parent->parent;
    		}
    		$idlang = icl_object_id(42, 'page', false );
    		$permalinkk = get_permalink( $idlang );
    		echo '<li><a href="' . $permalinkk . '">' . get_the_title($idlang) . '</a></li> ' . $delimiter . ' ';
    
    		if ( ! empty( $parents ) ) {
    			$parents = array_reverse( $parents );
    			foreach ( $parents as $parent ) {
    				$item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ));
    				echo  '<li><a href="' . get_term_link( $item->slug, 'categoria-producte' ) . '">' . $item->name . '</a></li>'. $delimiter;
    			}
    		}
    
    		$queried_object = $wp_query->get_queried_object();
    		echo $before . $queried_object->name . $after;	
    
        } elseif ( is_day() ) {
          echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ' . $delimiter . ' ';
          echo '<li><a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a></li> ' . $delimiter . ' ';
          echo $before . get_the_time('d') . $after;
    
        } elseif ( is_month() ) {
          echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ' . $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() == 'producte' ) {
    			echo $prepend;
    
    		$idlang = icl_object_id(42, 'page', false );
    		$permalinkk = get_permalink( $idlang );
    		echo '<li><a href="' . $permalinkk . '">' . get_the_title($idlang) . '</a></li> ' . $delimiter . ' ';
    
    			if ( $terms = wp_get_object_terms( $post->ID, 'categoria-producte' ) ) {
    				$term = current( $terms );
    				$parents = array();
    				$parent = $term->parent;
    
    				while ( $parent ) {
    					$parents[] = $parent;
    					$new_parent = get_term_by( 'id', $parent, 'categoria-producte' );
    					$parent = $new_parent->parent;
    				}
    
    				if ( ! empty( $parents ) ) {
    					$parents = array_reverse($parents);
    					foreach ( $parents as $parent ) {
    						$item = get_term_by( 'id', $parent, 'categoria-producte');
    						echo '<li><a href="' . get_term_link( $item->slug, 'categoria-producte' ) . '">' . $item->name . '</a></li>' . $delimiter;
    					}
    				}
    
    				echo '<li><a href="' . get_term_link( $term->slug, 'categoria-producte' ) . '">' . $term->name . '</a></li>' . $delimiter;
    
    			}
    
    			echo $before . get_the_title() . $after;
    	  }
    	  elseif ( get_post_type() != 'post' ) {
            $post_type = get_post_type_object(get_post_type());
            $slug = $post_type->rewrite;
            echo '<li><a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a></li> ' . $delimiter . ' ';
            echo $before . get_the_title() . $after;
          }
    
    	   else {
            $cat = get_the_category(); $cat = $cat[0];
            echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
            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];
          echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
          echo '<li><a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a></li> ' . $delimiter . ' ';
          echo $before . get_the_title() . $after;
    
        } elseif ( is_page() && !$post->post_parent ) {
          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[] = '<li><a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a></li>';
            $parent_id  = $page->post_parent;
          }
          $breadcrumbs = array_reverse($breadcrumbs);
          foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
          echo $before . get_the_title() . $after;
    
        } elseif ( is_search() ) {
          echo $before . 'Search results for "' . get_search_query() . '"' . $after;
    
        } elseif ( is_tag() ) {
          echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
    
        } elseif ( is_author() ) {
           global $author;
          $userdata = get_userdata($author);
          echo $before . 'Articles posted by ' . $userdata->display_name . $after;
    
        } elseif ( is_404() ) {
          echo $before . 'Error 404' . $after;
        }
    
        if ( get_query_var('paged') ) {
          if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
          echo __('Page', 'bootstrapwp') . ' ' . get_query_var('paged');
          if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
        }
    
        echo '</ul>';
    
      }
    } // end bootstrapwp_breadcrumbs()

    The web in development that is using this codes is here:
    https://plasticosjobgar.com/webwp/productes/

    To translate “Home” just use WPML String translation. Search for “Home” under “Select strings within context: plugin breadcrumbs-navxt”.

    Hi Aiwe, I tried this and didn’t work, I think the string that appears in the “select strings within context: plugin breadcrumbs-navxt”, which I translated without results, come from a label of the plugin, not from the variable input that people can change in the admin plugin’s interface.

    You are right, try instead searching for “Home” in general, you’ll likely find it two times, try adding translations in plugin breadcrumb-trail context.

    I did it when I was trying to resolve the problem, I search and translated all the “home” srtings, but it didn’t work at all. Maybe I forgot something.
    Are you sure that it works? Did you tried?
    Now I can’t do more testing in this issue, because I have resolved the problem with the script posted above and I have not yet more the plugin installed and no more time to explore the thing, but would be interesting to know a solution for the plugin.

    Yes I made translations using WPML’s String translation and it worked for me. Now “Home” IS translated in different languages. Everything I translate there is working for me so far.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Breadcrumb NavXT and WPML’ is closed to new replies.