0

I need to change "Last updated on" and "Posted on" From the code below to another words in arabic.

This code is part of the "template-tags.php" file which is part of the WordPress theme files

I just tried replacing the words but it didn't work for me

It just looks like this"����������"

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

1 Answers1

0

There seems to be no problem with the code. You can apply these changes to see if it works.

Using 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;

Notice that I

<? Php
endif;

I added myself, it will probably be different from your code and still continue.

Or you can use utf8_encode like this:

<?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;

And if the above did not work. You should check to see if there is a UTF-8 meta on your page. <meta charset="utf-8"> This meta should be in your header.php file. If not, add it. If you did all the work but did not answer, use a standard Arabic or Persian font

Morteza Barati
  • 329
  • 3
  • 11