I am a newbie in PHP & wordpress. I wanted to know how to make this codde renders the date formating in french (e.g. 5 Fev) when your on the french side but in english format in English (e.g. Jan 5)
Here is my code:
<?php
if (strtolower(ICL_LANGUAGE_CODE) == 'en') {$sidePosts = get_posts('cat=3,4,5,19&posts_per_page=5&order=DESC&orderby=date');}
if (strtolower(ICL_LANGUAGE_CODE) == 'fr')开发者_C百科 {$sidePosts = get_posts('cat=9,10,11,17&posts_per_page=5&order=DESC&orderby=date');}
foreach($sidePosts as $sidePosts) {
$array = (array) $sidePosts;
print("<li>");
print("<span class='date'>".get_the_time('M j', $array[ID])."</span>");
print("<a href='".get_permalink($array[ID])."' title='".$array[post_title]."'>".$array[post_title]."</a>");
print("</li>");
}
?>
You could replace this:
print("<span class='date'>".get_the_time('M j', $array[ID])."</span>");
with this:
if (strtolower(ICL_LANGUAGE_CODE) == 'en')
{
print("<span class='date'>".get_the_time('M j', $array[ID])."</span>");
}
else {
print("<span class='date'>".get_the_time('j M', $array[ID])."</span>");
}
In the long run you may want to look at using a plugin to do this since you will likely have to redo this change after updating wordpress.
You may also want to read this: http://codex.wordpress.org/Formatting_Date_and_Time and http://gettingeek.com/internationalize-localize-a-wordpress-theme-guide-for-dummies-part-1-introduction-70.html
精彩评论