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 '); |