Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #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.

    #303859

    Hi 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ünter

    #303909

    Hello 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!

    #304095

    Hi!

    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.
    #304244

    Thank you for looking into this topic, Josue. Unfortunately it still doesn`t work with the new code.

    #304247

    Hi!

    I modified my message, please try it again.

    Cheers!
    Josue

    #304269

    Still no luck ;-).

    #304276

    Hey!

    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ünter

    #304282

    Sorry, it still doesn`t work. But I really appreciate your support!

    #304483

    Hey!

    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!
    Peter

    #304550

    Hey Peter,
    I am really sorry, but unfortunately both codes don`t work.

    Best Regards, Simon

    #304617

    Hi,

    Can you please create us an administrator account? post it here as a private reply.

    Regards,
    Josue

    #307501

    I 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.

    #307510

    You are welcome, glad we could help :)

    Regards,
    Josue

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Rename "Portfolio item" in search results (with german translation)’ is closed to new replies.