我需要更改"上次更新时间为";以及";张贴在";从下面的代码到另一个阿拉伯语单词。
该代码是";template-tags.php";文件,这是WordPress主题文件的一部分
我只是试着替换单词,但对我来说不起作用
它只是看起来像这样"����������">
<?php if ( get_theme_mod('show_post_date', '1') == 1 ) : ?>
<div class="entry-date"><i class="fa fa-clock-o"></i><span >
<?php $u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 60) {
echo "Last updated on "; // here
the_modified_time('Y-m-d');
}
else {echo "Posted on "; // here
the_time('Y-m-d');
} ?>
代码似乎没有问题。您可以应用这些更改来查看它是否有效。
使用htmlentities
<?php if (get_theme_mod('show_post_date', '1') == 1) : ?>
<div class="entry-date"><i class="fa fa-clock-o"></i><span>
<?php $u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 60) {
$text = 'آخر تحديث في';
echo htmlentities($text, ENT_QUOTES, "UTF-8"); // here
the_modified_time('Y-m-d');
} else {
$text = 'نشر على';
echo htmlentities($text, ENT_QUOTES, "UTF-8"); // here
the_time('Y-m-d');
} ?>
<?php
endif;
注意,我
<? Php
endif;
我补充道,它可能会与您的代码不同,并且仍然会继续。
或者你可以像这样使用utf8_encode
:
<?php if (get_theme_mod('show_post_date', '1') == 1) : ?>
<div class="entry-date"><i class="fa fa-clock-o"></i><span>
<?php $u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 60) {
$text = 'آخر تحديث في';
echo utf8_encode($text); // here
the_modified_time('Y-m-d');
} else {
$text = 'نشر على';
echo utf8_encode($text); // here
the_time('Y-m-d');
} ?>
<?php
endif;
如果上述方法不起作用。您应该检查页面上是否有UTF-8
元。<meta charset="utf-8">
此元数据应在您的header.php
文件中。如果没有,请添加它。如果你做了所有的工作但没有回答,请使用标准的阿拉伯语或波斯语字体