Solve the problem of coding in WordPress templates


I liked to talk about the coding problem that I faced before when I localized one of the templates that I offered to one of the brothers Zaman, and I also faced the same problem with the templates that were designed. This problem lies in two lines in the template and they are responsible for it. You may also encounter designs programmed with html5. I will put a backup solution in case you encounter the same problem. The important thing is to get to the heart of the matter

The problem I’m talking about lies in the appearance of question marks or incomprehensible codes and it has nothing to do with the rule but its relationship with the browser. As for the rule, you can check the wp-config.php file. Note the following code:

/** encoding database */
define("DB_CHARSET", "utf8");

This is an illustration of the problem

charset-problem

To fix this problem, all you have to do is open the header.php file in the second line of the template and change the dir and lang if the template is designed in xhtml, for example:

Or you will find this code:

<html xmlns=”http://www.w3.org/1999/xhtml” dir=”ltr” lang=”en”>

We change the line to:

<html <?php language_attributes(); ?>>

For the other line in the header.php file, search for charset. If the template uses WordPress code to display the markup, you will find this code:

<html xmlns=”http://www.w3.org/1999/xhtml” dir=”rtl” lang=”ar”>

We change the line to:

<meta charset=”<?php bloginfo( “charset” ); ?>” />

For HTML5, you only need to change the following codes:

Sometimes you will find the html tag only like this:

<meta http-equiv=”Content-Type” content=”text/html;charset=utf-8″ >

Without any addition, and again you will find this way:

<html>

We change it to:

<html lang=”ar” dir=”rtl”>

If you make the changes mentioned, make sure that you will not encounter the encoding problem again

May God help you and see you in another post, God willin

Leave a Comment