Tagged: breadcrumb, category, Portfolio, translation
-
AuthorPosts
-
February 21, 2018 at 1:19 pm #915427
Hi,
Coming back on an issue that finally needs to be solved properly…
Please look at the breadcrumb in following single portfolio page: U bevindt zich hier: Home / Boeken / Noortje / Noortje viert carnaval.
When you click on language English, you will see the English version of the same book with the following breadcrumb: You are here: Home / Boeken / Noortje / Noortje Celebrates Carnival.
The category name “Boeken” is somehow not being translated into “Books”. Please see also attached screen prints for clarification.
Can you explain why this is going wrong and what I can do to solve this?
Thanks & regards,
MoniqueFebruary 21, 2018 at 3:02 pm #915485Hey Monique,
Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?
Best regards,
VictoriaFebruary 21, 2018 at 3:24 pm #915499Hi Victoria,
Please find below.
Note: please do not change the WP read settings nor Enfold Child page settings! The settings as it is now is needed in combination with Polylang. If you change it the whole multi language page and post structure won’t work anymore as it should.
Looking forward to your further info.
Regards,
MoniqueFebruary 21, 2018 at 3:50 pm #915530Hi,
Best regards,
VictoriaFebruary 21, 2018 at 4:07 pm #915542Hi Victoria,
Thanks for your quick reply. I understand what you mean: the two pages were both in English, I did not “connect” the correctly. I’ve corrected this, so we now have one page in Dutch “Boeken” and one page in English “Books”. However that does not solve the breadcrumb issue… :-(
Please advise.
Regards,
MoniqueFebruary 22, 2018 at 4:19 am #915840Hi Monique,
Do you have the database cache? It takes Dutch page for the breadcrumbs, not the English one.
Best regards,
VictoriaFebruary 22, 2018 at 4:21 am #915842Hi,
Thank you for the update. We added this filter in the functions.php file.
// portfolio breadcrumb add_filter( 'avia_breadcrumbs_trail', 'avia_breadcrumbs_trail_mod', 20, 2 ); function avia_breadcrumbs_trail_mod( $trail, $args ) { if( is_singular('portfolio') && pll_current_language() == 'en' ) { $home = $trail[0]; $last = array_pop($trail); $books = get_post(480); if(!empty($books)) { $link = '<a href="'.get_the_permalink($books->ID).'">'.$books->post_title.'</a>'; $link = preg_replace('!rel=".+?"|rel=\'.+?\'|!',"", $link); $link = str_replace('<a ', '<a rel="v:url" property="v:title" ', $link); $link = '<span typeof="v:Breadcrumb">'.$link.'</span>'; $trail[1] = $link; $trail = array(0 => $home, 1 => $link, 2 => $trail[2], 'trail_end' => $last); } } return $trail; }
The filter should return the “books” page on the single portfolio page and only if the language is set to English.
Best regards,
Ismael- This reply was modified 6 years, 9 months ago by Ismael.
February 22, 2018 at 10:32 am #915951Hi Ismael,
This is really great! You guys rock! The 5 stars you get are well deserved :-)
One more question. I had exactly the same problem with my own website. Thought to change your am code to get it to work there too, but I get a blank page. So obviously I missed something. The code I thought to use is:
// portfolio breadcrumb add_filter( 'avia_breadcrumbs_trail', 'avia_breadcrumbs_trail_mod', 20, 2 ); function avia_breadcrumbs_trail_mod( $trail, $args ) { if( is_singular('portfolio') && pll_current_language() == 'en' ) { $home = $trail[0]; $last = array_pop($trail); $my-work = get_post(4818); if(!empty($my-work)) { $link = '<a href="'.get_the_permalink($my-work->ID).'">'.$my-work->post_title.'</a>'; $link = preg_replace('!rel=".+?"|rel=\'.+?\'|!',"", $link); $link = str_replace('<a ', '<a rel="v:url" property="v:title" ', $link); $link = '<span typeof="v:Breadcrumb">'.$link.'</span>'; $trail[1] = $link; $trail = array(0 => $home, 1 => $link, 2 => $trail[2], 'trail_end' => $last); } }
Could you please verify? Login details below.
Thanks & regards,
MoniqueFebruary 23, 2018 at 2:36 pm #916705Hi Monique,
This is not a correct way to name a variable https://cl.ly/0v0M1C0p3N14
Change it to $myWork and try the code again.Best regards,
VictoriaMarch 9, 2018 at 12:59 pm #924459Hi Victoria,
I assume that sometimes you LOL? ;-)
Sorry but I seem not to be able to get this to work. Either the page turns blank or the breadcrumb gets completely mixed up…
Would you please be so kind to submit me the full code to get the breadcrumb right on a single portfolio page in English? Speaking with Ismael’s words: the filter should return the “My Work” page on the single portfolio page and only if the language is set to English.
Thanks & regards,
MoniqueMarch 10, 2018 at 10:27 pm #925050Hi,
Try the code as following
// portfolio breadcrumb add_filter( 'avia_breadcrumbs_trail', 'avia_breadcrumbs_trail_mod', 20, 2 ); function avia_breadcrumbs_trail_mod( $trail, $args ) { if( is_singular('portfolio') && pll_current_language() == 'en' ) { $home = $trail[0]; $last = array_pop($trail); $myWork = get_post('4818'); if(!empty($myWork)) { $link = '<a href="'.get_the_permalink($my-work->ID).'">'.$my-work->post_title.'</a>'; $link = preg_replace('!rel=".+?"|rel=\'.+?\'|!',"", $link); $link = str_replace('<a ', '<a rel="v:url" property="v:title" ', $link); $link = '<span typeof="v:Breadcrumb">'.$link.'</span>'; $trail[1] = $link; $trail = array(0 => $home, 1 => $link, 2 => $trail[2], 'trail_end' => $last); } }
If not work, share us access. Maybe one of the variables are wrong.
Best regards,
BasilisMarch 14, 2018 at 1:04 pm #926581Hi Basilis,
Unfortunately the site turns blank with this code. Please find access details below.
Regards,
MoniqueMarch 15, 2018 at 8:40 pm #927662Hi,
can u also send ftp – just if we brake something :)
Best regards,
BasilisMarch 16, 2018 at 10:52 am #928014Hi Basilis,
Please find below.
Best regards,
MoniqueMarch 20, 2018 at 7:02 am #929538Hi,
Thank you for the info. We added the code in the functions.php file. Please remove browser cache or do a hard refresh before checking the page.
Best regards,
IsmaelMarch 20, 2018 at 1:33 pm #929822Wow you’re really great! Thanks so much for your help!
Can you flag this topic as solved please?
Best regards,
MoniqueMarch 20, 2018 at 5:28 pm #929982Hi,
Sure, glad that this is resolved. Thanks for using Enfold and have a great day :)
Best regards,
Nikko -
AuthorPosts
- The topic ‘Portfolio category name in breadcrumb not translated’ is closed to new replies.