我想在本地化编号中显示post视图。我在函数中添加这些函数。php这样做
function make_bangla_number($str)
{
$engNumber = array(1,2,3,4,5,6,7,8,9,0);
$bangNumber = array(\'১\',\'২\',\'৩\',\'৪\',\'৫\',\'৬\',\'à§\',\'৮\',\'৯\',\'০\');
$converted = str_replace($engNumber, $bangNumber, $str);
return $converted;
}
add_filter( \'the_views\', \'make_bangla_number\' );
但我无法在本地化中显示数字。无论何时我呼叫\\u views,它都会显示英文号码。你知道如何用本地化语言显示post视图编号吗?有关更多信息,请参阅我的后期查看功能:
// function to count post views.
function setPostViews($postID) {
$count_key = \'views\';
$count = get_post_meta($postID, $count_key, true);
if($count==\'\'){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, \'0\');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
// function to display number of post views.
function the_views($postID){
$count_key = \'views\';
$count = get_post_meta($postID, $count_key, true);
if($count==\'\'){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, \'0\');
return "0 View";
}
return $count.\' বার\';
}
我安装了孟加拉语言包,我的站点字符集也是UTF-8。孟加拉语语言包可以将英语数字转换为孟加拉语数字。所以我使用这个代码。有了它,我可以用孟加拉文转换日期,但无法转换视图。所以我在这里。