WordPress 中文文档
Fun Character Entities
出自WordPress Chinese 中文文档
Character Entities or Extended Characters
In many WordPress sites, you will see odd symbols that will pop up from time to time. Often these symbols appear in navigation links. For instance, look at the the double left angle quotes (laquo;) and the double right angle quotes (raquo;) in this example:
div style=border:1px solid blue; width:50%; margin:20px; padding:20pxlaquo; laquo; Previous Post Titlenbsp;nbsp;nbsp;nbsp;|nbsp;nbsp;nbsp;nbsp;Next Post Title raquo; raquo; /div
These symbols are called HTML character entities or extended characters. They are generated by strange looking code on the web page that the web browser interprets as symbols.
The code that generated the above example looks like this: pre?php previous_post('amp;laquo; amp;laquo; %', , 'yes'); ? | ?php next_post('% amp;raquo; amp;raquo; ', , 'yes'); ?/pre
Some of the most popular HTML character entities are:
div style=font-size:110%
- ttamp;raquo;/ttnbsp;nbsp;nbsp;nbsp;nbsp;raquo;nbsp;nbsp;nbsp;nbsp;nbsp;double right angle quotebr /
- ttamp;laquo;/ttnbsp;nbsp;nbsp;nbsp;nbsp;laquo; nbsp;nbsp;nbsp;nbsp;nbsp;double left angle quotebr /
- ttamp;lt;/ttnbsp;nbsp;nbsp;nbsp;nbsp;lt; nbsp;nbsp;nbsp;nbsp;nbsp;single left arrowbr /
- ttamp;gt;/ttnbsp;nbsp;nbsp;nbsp;nbsp;gt; nbsp;nbsp;nbsp;nbsp;nbsp;single right arrowbr /
- ttamp;bull;/ttnbsp;nbsp;nbsp;nbsp;nbsp;bull; nbsp;nbsp;nbsp;nbsp;nbsp;bulletbr /
- ttamp;#9829;/ttnbsp;nbsp;nbsp;nbsp;nbsp;ornbsp;nbsp;nbsp;nbsp;nbsp;ttamp;hearts;/tt nbsp;nbsp;nbsp;nbsp;nbsp;hearts; nbsp;nbsp;nbsp;nbsp;nbsp;black heartbr /
- ttamp;#9830;/ttnbsp;nbsp;nbsp;ornbsp;nbsp;nbsp;ttamp;diams;/ttnbsp;nbsp;nbsp;nbsp;nbsp;#9830; nbsp;nbsp;nbsp;black diamondbr /
- ttamp;#9827;/ttnbsp;nbsp;nbsp;ornbsp;nbsp;nbsp;ttamp;clubs;/ttnbsp;nbsp;nbsp;#9827; nbsp;nbsp;nbsp;black clubs (shamrock)br /
- ttamp;#9824;/ttnbsp;nbsp;nbsp;ornbsp;nbsp;nbsp;ttamp;spades;/ttnbsp;nbsp;nbsp;nbsp;nbsp;#9824; nbsp;nbsp;nbsp;nbsp;nbsp;black spadebr /
- ttamp;#8734;/ttnbsp;nbsp;nbsp;nbsp;#8734; nbsp;nbsp;nbsp;nbsp;nbsp;infinity symbolbr /
- ttamp;mdash;/ttnbsp;nbsp;nbsp;nbsp;mdash; nbsp;nbsp;nbsp;nbsp;nbsp;long dashbr /
/div
Using Character Entities in WordPress
Using character entities can be a fun part of your design! You can use these special accents with template tags such as the ttthe_category()/tt tag. Note: ttthe_category()/tt template tag lists, in post meta data section, the various categories assigned to a post.
In this example, the special character entity, the heart (hearts;) symbol, separates the categories of WordPress, Computers, and Internet News:
pre?php the_category(' amp;hearts; ') ?/pre
div style=font-size: 105%; color: blue; font-weight:bold; margin:20px; padding: 20px; border:solid 1px blueWordPress hearts; Computers hearts; Internet News/div
In this example you see the use of an accent in your post's title:
pre?php the_title('amp;#8734; ', ' amp;#8734;'); ? /pre
div style=font-size: 120%; color: blue; font-weight:bold; margin:20px; padding: 20px; border:solid 1px blue#8734; WordPress Makes Me Smile #8734;/div
If you want to highlight the post's author, you don't have to use a character entity inside of a WordPress template tag. You can use it in the text.
prediv id=authoramp;diams; ?php the_author(); ?/div/pre
div style=color: blue; font-weight:bold; margin:20px; padding: 20px; border:solid 1px bluediams; Harriet Smith/div
As you have seen, there are a many uses for character entities within your site. With this information you can experiment and find creative ways to use these symbols in your design!
- Note: Not all template tags can use character entities, especially those tags that use boolean parameters. Test a template tag thoroughly to be sure that it will accept the symbols.

