网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > WordPress
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 117.95.104.248
Old 2010-11-03, 09:46 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default How to Show Category and Tag Descriptions In WordPress Theme

WordPress lets you add a short description to the categories as well as to the post tags of your blog. Here is a brief tutorial to show the category and tag descriptions in your WordPress theme.

Why category and tag descriptions? You may ask. Adding descriptions to category and tag pages has two advantages. First, the reader of your blog can have a rough idea on the type of posts are covered in a particular category. Second, you can show the category and tag descriptions as meta description on the respective pages which may help for better SEO.


Show Category Description in Category Pages Of WordPress Theme
1. First, add a description to your categories from WordPress Dashboard > Categories.

2. Open your FTP client, browse to your WordPress theme directory and download the archive.php file for editing. Better, create a backup of the archive.php file to be safe.

3. You will see a code block like the following:

4. Paste the following code just below it.

<?php if (is_category()) { ?>
<?php $description=category_description(); echo $description; ?>
<?php } ?>The above code pulls the category description that you entered in step 1 and displays the same to the user.

5. For the meta description part, add the following code before the </head> tag in your WordPress theme.

<?php
if (is_category()) { ?>
<meta name=”description” content=”<?php $description=category_description(); echo $description; ?>” />
<?php } ?>

====================

Show Tag Descriptions in Tag Pages Of WordPress Theme
To show the tag descriptions, follow steps 1, 2 and 3 as described in previous section and then continue with what follows next.

4. Paste the following code to show tag descriptions in every tag page.

<?php if (is_tag()) { ?><?php echo tag_description(); ?><?php } ?>You do not need to fill out each and every tag to use the above code. If a tag does not have any description, the above code shows nothing. (see example)

5. To display the tag descriptions as meta descriptions, put the following code before </head> in your WordPress theme.

<?php if ( is_tag() && tag_description() ) : ?>
<meta name=”description” content=”<?php echo wp_specialchars( strip_tags( tag_description() ), 1 ); ?>” />
<?php endif; ?>

=================

Styling Category and Tag descriptions
To style the category and tag descriptions, all you have to do is include a unique class just before the description field.

For example:

<?php if (is_tag()) { ?><div class=”yourclassname”><?php echo tag_description(); ?></div><?php } ?>Now, write the attributes of the div class in the style.css file of your WordPress theme.
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
wordpress tag car Blog(博客)/Wiki(维客)/RSS/Cms 0 2008-02-10 10:46 PM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 06:29 PM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.