$8
Theme localization in a query...
Hello,
I am localizing my theme up for translation strings.
Using generic...
<h5><?php _e('Contact','mytheme'); ?></h5>But I've got some query's that include text in the query itself.
Example...
<?php wp_list_bookmarks(array(
'orderby' => 'rating',
'order' => 'ASC',
'limit' => 10,
'category_name' => 'Our Friends',
'title_before' => '<h5>',
'title_after' => '</h5>',
'link_before' => '<span>»</span> '
) ); ?>How do I localize the the 'Our friends' text?
I've tried this...
<?php wp_list_bookmarks(array(
'orderby' => 'rating',
'order' => 'ASC',
'limit' => 10,
'category_name' => . __('Our Friends', 'mytheme') .,
'title_before' => '<h5>',
'title_after' => '</h5>',
'link_before' => '<span>»</span> '
) ); ?>But this does not work?
Any ideas...
Also while on i'm topic... I have the same problem with stuff in my functions...
function search_form_header( $form ) {
$form = '<form method="get" id="searchform-header" action="' . home_url( '/' ) . '" >
<div>
<input class="pie" type="text" value="" name="s" id="s" />
<input class="pie" type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
<input type="hidden" name="lang" value="' . __ (ICL_LANGUAGE_CODE) . '"/>
</div>
</form>';
return $form;
}
add_filter( 'get_search_form', 'search_form_header' );If you look at... value="'. esc_attr__('Search') .'"
How do I localize this?
Thanks
Josh
Josh Cranwell | 01/27/12 at 2:55pm
| Edit
(3) Possible Answers Submitted...
-

Last edited:
01/27/12
3:00pmFrancisco Javier Carazo Gil says:Hi Josh,
Before executing this:
<?php wp_list_bookmarks(array(
'orderby' => 'rating',
'order' => 'ASC',
'limit' => 10,
'category_name' => . __('Our Friends', 'mytheme') .,
'title_before' => '<h5>',
'title_after' => '</h5>',
'link_before' => '<span>»</span> '
) ); ?>
You have to save value of category_name in a var and then call the query with this var.- 01/27/12 3:05pm
Francisco Javier Carazo Gil says:Something like this:
$my_category_name = __('Our Friends', 'mytheme');
And then:
'category_name' => $my_category_name, - 01/27/12 3:06pm
Josh Cranwell says:Hmmm... I'm not sure how to do this?
- 01/27/12 3:28pm
Francisco Javier Carazo Gil says:Josh,
You have to do: $my_category_name = __('Our Friends', 'mytheme');
Before calling:
wp_list_bookmarks
- 01/27/12 3:29pm
Francisco Javier Carazo Gil says:And into wp_list_bookmarks you have to use this:
'category_name' => $my_category_name,
- 01/27/12 3:37pm
Josh Cranwell says:Perfecto!!!
Thank you! - 01/27/12 3:38pm
Josh Cranwell says:Perfecto!!!
Thank you!
- 01/27/12 3:05pm
-

Last edited:
01/27/12
3:03pmLuis Abarca says:First, you can use category ID instead of category name
<?php wp_list_bookmarks(array(
'orderby' => 'rating',
'order' => 'ASC',
'limit' => 10,
'category' => "2", // the category ID of "Our friends"
'title_before' => '<h5>',
'title_after' => '</h5>',
'link_before' => '<span>»</span> '
) ); ?>
Second, just add the domain
function search_form_header( $form ) {
$form = '<form method="get" id="searchform-header" action="' . home_url( '/' ) . '" >
<div>
<input class="pie" type="text" value="" name="s" id="s" />
<input class="pie" type="submit" id="searchsubmit" value="'. esc_attr__('Search', 'yourtheme') .'" />
<input type="hidden" name="lang" value="' . __ (ICL_LANGUAGE_CODE) . '"/>
</div>
</form>';
return $form;
}
add_filter( 'get_search_form', 'search_form_header' );Previous versions of this answer: 01/27/12 at 3:03pm
- 01/27/12 3:26pm
Luis Abarca says:You can use get_term_by, ti get the category ID
<?php
$ourfriends = get_term_by('slug', 'our-friends', 'category');
wp_list_bookmarks(array(
'orderby' => 'rating',
'order' => 'ASC',
'limit' => 10,
'category' => $ourfriends->term_id, // the category ID of "Our friends"
'title_before' => '<h5>',
'title_after' => '</h5>',
'link_before' => '<span>»</span> '
) );
?> - 01/27/12 3:28pm
Josh Cranwell says:Thanks Luis, the search worked...
How ever, on my other search form... it's not working....
See below value 'Search Downloads'
function search_form_download( $form ) {
$form = '<form method="get" id="searchform-download" action="' . home_url( '/' ) . '" >
<div>
<input type="text" value="' . __('Search Downloads','mytheme') . '" name="s" id="s-download" class="clearit" />
<input type="hidden" name="post_type" value="download" />
<input type="hidden" name="lang" value="' . __ (ICL_LANGUAGE_CODE) . '"/>
</div>
</form>';
return $form;
}
Have I done it wrong? Thanks
- 01/27/12 3:36pm
Luis Abarca says:Try to change the function to esc_attr__()
function search_form_download( $form ) {
$form = '<form method="get" id="searchform-download" action="' . home_url( '/' ) . '" >
<div>
<input type="text" value="' . esc_attr__('Search Downloads','mytheme') . '" name="s" id="s-download" class="clearit" />
<input type="hidden" name="post_type" value="download" />
<input type="hidden" name="lang" value="' . __ (ICL_LANGUAGE_CODE) . '"/>
</div>
</form>';
return $form;
}
- 01/27/12 3:37pm
Josh Cranwell says:No it worked the first time, it was WPML not registering new strings on browser refresh. Thanks for you help :-)
- 01/27/12 3:26pm
-

Last edited:
01/27/12
3:02pmJohn Cotton says:Have you tried with that line reading:
'category_name' => __('Our Friends', 'mytheme'),
?- 01/27/12 3:38pm
Josh Cranwell says:Hi John,
Thanks for help, think Francisco J answered first
- 01/27/12 3:38pm
This question has expired.
John Cotton had additional discourse to offer.
Gabriel Reguly, idt, Josh Cranwell, Julio Potier voted on this question.
Current status of this question: Completed




