简体   繁体   English

在Wordpress边栏中显示Unicode字符

[英]Display Unicode character in Wordpress sidebar

I have created a custom sidebar with some Unicode characters but I have problem when viewing my Unicode characters. 我创建了带有一些Unicode字符的自定义边栏,但是查看Unicode字符时遇到问题。 This is my sidebar code: 这是我的侧边栏代码:

<?php
/**
* The Sidebar containing the main widget areas.
*
* @package Theme Meme
*/
?>
<div class="col-md-4 site-sidebar" role="complementary">
<?php do_action( 'before_sidebar' ); ?>
<?php if ( ! dynamic_sidebar( 'post_group_sidebar' ) ) : ?>
    <h3 class="widget-title">Title in Unicodé</h3> </br>
<?php endif; ?>
</div>

I am not sure how to make it work, perhaps I have to add a meta tag to display the Unicode somewhere? 我不确定如何使其工作,也许我必须添加一个元标记以在某处显示Unicode?

Many thanks for your help 非常感谢您的帮助

Ok so I am thinking whether the Sidebar is showing any content from a Database? 好的,所以我在考虑补充工具栏是否显示了数据库中的任何内容? You can always change your Database Coaltion to utf8_general_ci 您可以随时将数据库联盟更改为utf8_general_ci

Here is how to do it 这是怎么做的

1) Open and edit your wp-config.php file in the root of your Wordpress Website and replace the default DB_CHARSET and DB_COLLATE lines with this instead: 1)在Wordpress网站的根目录中打开并编辑wp-config.php文件,并用以下内容替换默认的DB_CHARSETDB_COLLATE行:

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8mb4');

/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', 'utf8_general_ci' );

Save it back and see if that works. 保存回去,看看是否可行。

Else you can also include one of the lines below in your PHP or HTML code. 另外,您还可以在PHP或HTML代码中包含以下几行之一。

In your code for PHP include this on top of your PHP Code: 在您的PHP代码中,在PHP代码之上包括以下代码:

header('Content-type: text/html; charset=UTF-8');

In HTML add the line below in between the <head></head> Tags or somewhere above the tag: 在HTML中,在<head></head>标记之间或标记上方的某处添加以下行:

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

Best of luck! 祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM