2010-05-05 169 views
1

我是PHP的新手& wordpress。我想知道如何使這個codde呈現在法語(例如5 FEV),日期格式化,當你在法國的一面,但在英語格式(如1月5日)法國日期格式

這裏是我的代碼:

<?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') {$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>"); 
} 
?> 

回答

0

你可以取代這個:

print("<span class='date'>".get_the_time('M j', $array[ID])."</span>"); 

與此:

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>"); 
} 

從長遠看你可能想看看使用一個插件來做到這一點,因爲你可能不得不在更新WordPress後重做這個改變。

您可能還需要閱讀此:http://codex.wordpress.org/Formatting_Date_and_Timehttp://gettingeek.com/internationalize-localize-a-wordpress-theme-guide-for-dummies-part-1-introduction-70.html

+0

謝謝你工作很喜歡一個迷住了。 – 2010-05-10 13:46:31