WordPress:Fun Character Entities

来自站长百科
Xxf3325讨论 | 贡献2008年4月10日 (四) 09:41的版本 (新页面: =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 ins...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

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 («) and the double right angle quotes (») in this example:

[[WordPress:#Character Entities or Extended Characters|« « Previous Post Title]]    |    [[WordPress:#Character Entities or Extended Characters|Next Post Title » » ]]

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:

<?php previous_post('&laquo; &laquo; %', '', 'yes'); ?>
| <?php next_post('% &raquo; &raquo; ', '', 'yes'); ?>

Some of the most popular HTML character entities are:

&raquo;     »     double right angle quote
&laquo;     «      double left angle quote
&lt;     <      single left arrow
&gt;     >      single right arrow
&bull;     •      bullet
&#9829;     or     &hearts;      ♥      black heart
&#9830;   or   &diams;     ♦    black diamond
&#9827;   or   &clubs;   ♣    black clubs (shamrock)
&#9824;   or   &spades;     ♠      black spade
&#8734;    ∞      infinity symbol
&mdash;    —      long dash

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 the_category() tag. Note: the_category() template tag lists, in post meta data section, the various categories assigned to a post.

In this example, the special character entity, the heart () symbol, separates the categories of WordPress, Computers, and Internet News:

<?php the_category(' &hearts; ') ?>
WordPress ♥ Computers ♥ Internet News

In this example you see the use of an accent in your post's title:

<?php the_title('&#8734; ', ' &#8734;'); ?> 
∞ WordPress Makes Me Smile ∞

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.

<div id="author">&diams; <?php the_author(); ?></div>
♦ Harriet Smith

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.


Character Entities Resources