Tagged: german, portfolio item, Rename, umlaut
-
AuthorPosts
-
August 13, 2014 at 2:13 pm #303823
I just found this topic about renaming the labels of the search results.
While @Ismaels solution works perfect with my custom post types, it doesn´t work for my portfolio items. I am using the german version of enfold and here “portfolio items” are translated to “Portfolio Einträge”. The problem is that the solution doens´t work if a german umlaut (in this case “ä”) is inside the label name.add_filter('avf_ajax_search_label_names','avf_ajax_search_assign_label_names', 10, 1); function avf_ajax_search_assign_label_names($label) { if($label == 'Portfolio Einträge') { $label = 'Mitarbeiter'; } else if($label == 'Produkte') { $label = 'Downloads'; } else { $label = $label; } return $label; }
If I change the translation (.po / .mo files) to a name without “ä” (e.g. from “Portfolio Einträge” to “Portfolio Eintraege”), it works without a problem. Do you have any idea of how to get the code to work with the german translation? Thanks.
August 13, 2014 at 3:02 pm #303859Hi StuWeTueHo!
Thank you for using our theme.
The only reason why the code above does not work, can be one or more spaces in the translation text at beginning or end.
Try to replace the rext with the following:
add_filter('avf_ajax_search_label_names','avf_ajax_search_assign_label_names', 10, 1); function avf_ajax_search_assign_label_names($label) { $label = trim($label); if($label == 'Portfolio Einträge') { $label = 'Mitarbeiter'; } else if($label == 'Produkte') { $label = 'Downloads'; } else { $label = $label; } return $label; }
Cheers!
GünterAugust 13, 2014 at 4:17 pm #303909Hello Günter,
thanks for your quick response. I tried it with the provided code, but unfortunately it doesn`t work.
In my opinion the “umlaut” is causing the problem. I renamed “Portfolio Einträge” via po/mo files to different names. It always works, except if there is an umlaut inside the new name.Any other suggestions? Thanks!
August 14, 2014 at 1:16 am #304095Hi!
Try the following:
add_filter('avf_ajax_search_label_names','avf_ajax_search_assign_label_names', 10, 1); function avf_ajax_search_assign_label_names($label) { if(htmlentities($label) == 'Portfolio Einträge') { $label = 'Mitarbeiter'; } else if($label == 'Produkte') { $label = 'Downloads'; } else { $label = $label; } return $label; }
Regards,
Josue- This reply was modified 10 years, 4 months ago by Josue.
August 14, 2014 at 9:30 am #304244Thank you for looking into this topic, Josue. Unfortunately it still doesn`t work with the new code.
August 14, 2014 at 9:40 am #304247Hi!
I modified my message, please try it again.
Cheers!
JosueAugust 14, 2014 at 10:11 am #304269Still no luck ;-).
August 14, 2014 at 10:26 am #304276Hey!
Try the following:
add_filter('avf_ajax_search_label_names','avf_ajax_search_assign_label_names', 10, 1); function avf_ajax_search_assign_label_names($label) { $label = trim($label); if(strcasecmp($label, 'Portfolio Einträge') == 0) { $label = 'Mitarbeiter'; } else if(strcasecmp($label,'Produkte') == 0) { $label = 'Downloads'; } else { $label = $label; } return $label; }
Best regards,
GünterAugust 14, 2014 at 10:44 am #304282Sorry, it still doesn`t work. But I really appreciate your support!
August 14, 2014 at 5:10 pm #304483Hey!
I’m not sure if the $label variable really contains the string “Portfolio Einträge”. Try this code instead:
add_filter('avf_ajax_search_label_names','avf_ajax_search_assign_label_names', 10, 1); function avf_ajax_search_assign_label_names($label) { $label = trim($label); if($label == 'Portfolio Einträge' || $label == 'Portfolio Entries' ) { $label = 'Mitarbeiter'; } else if($label == 'Produkte') { $label = 'Downloads'; } else { $label = $label; } return $label; }
If it still doesn’t work insert this code:
add_filter('avf_ajax_search_label_names','avf_ajax_search_assign_label_names', 10, 1); function avf_ajax_search_assign_label_names($label) { $label = trim($label); if(strpos($a,'Portfolio') !== false) { $label = 'Mitarbeiter'; } else if($label == 'Produkte') { $label = 'Downloads'; } else { $label = $label; } return $label; }
into the functions.php file and check if the code starts to work.
Cheers!
PeterAugust 14, 2014 at 7:29 pm #304550Hey Peter,
I am really sorry, but unfortunately both codes don`t work.Best Regards, Simon
August 14, 2014 at 10:58 pm #304617Hi,
Can you please create us an administrator account? post it here as a private reply.
Regards,
JosueAugust 21, 2014 at 7:26 pm #307501I just found the solution. Somehow my functions.php file inside my child theme had the wrong coding. Changed it to UTF-8 and your code works without a problem (stupid me). But thanks for your help. This theme and your support is worth every penny! Thanks guys.
August 21, 2014 at 8:02 pm #307510You are welcome, glad we could help :)
Regards,
Josue -
AuthorPosts
- The topic ‘Rename "Portfolio item" in search results (with german translation)’ is closed to new replies.