


























我们使用WordPress程序建网站时,在后台创建了分类目录后,可以给分类目录添加分类描述。Wordpress分类描述可以帮助我们网站做SEO优化,可以用于分类的description标签,也可以用于增加分类目录关键词密度。

<?php echo category_description(); ?>
<?php echo category_description( $category_id ); ?>
<?php foreach((get_the_category()) as $category){echo $category->category_description;}?>
使用上面的代码调用Wordpress分类描述,会自动出现P标签,不适合用于description标签,可以使用下面的代码去除Wordpress分类描述的P标签。
<?php $cat_des = category_description(); echo str_replace(array("<p>","","</p>", "\r", "\n"),"",$cat_des);?>
//分类描述删除p标签
function xintheme_delete_cat_p($description) {
$description = trim($description);
$description = strip_tags($description,"");
return ($description);
}
add_filter('category_description', 'xintheme_delete_cat_p');
感谢xinthemes: https://www.xintheme.com/wpjiaocheng/49754.html
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。