WordPress Category catalog Display column description

Source: Internet
Author: User
Tags php file

Wordpess's catalog description can be filled in by the following function to display the description on the category page:

The code is as follows Copy Code

<?php echo category_description ();?>

You can also specify the display of a fixed classification description and a classification alias to display the description of the classification, you can see the official WordPress function:

The code is as follows Copy Code

<div><?php Echo category_description (3);?></div>

Using Category Slug

Displays the description of a category, using a category slug.


<?php Echo category_description (Get_category_by_slug (' Category-slug ')->term_id);?>

With Category Title

<div><strong><?php Single_cat_title (' currently browsing ');? ></strong>: <?php Echo Category_description ();?></div>

This invocation of the classification description will automatically in the description content plus paragraph label p, sometimes affect the layout of the page you need, so you have to use PHP's own function to remove this paragraph label p, the specific method is:

The code is as follows Copy Code

<?php Echo strip_tags (Category_description ());?>

But do not know why, through this processing of the classification description of the content, although not with the paragraph tag p, but still will be in the back of the content of a line, so you have to take this line to remove:

The code is as follows Copy Code

<?php Trim (Strip_tags (category_description ());?>

Of course, you can set the functions.php to let you call the default classification descriptor function without displaying these paragraphs and wrapping, by adding the following in the functions.php file:

  code is as follows copy code

function hy _nohtml ($STR) { 
    return Trim (Strip_tags ($STR));
}
Add_filter (' category_description ', ' hy_nohtml ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.