所谓分类描述信息指的是,如下图所示:
这个字段在一些主题中会显示,或者在SEO的 description 中使用。
函数原型:
term_description( int $term, null $deprecated = null ): string
参数说明:
$term,分类ID。
$deprecated,这个参数已无用,只是为了兼容老代码而保留。
函数源码:
function term_description( $term = 0, $deprecated = null ) {
if ( ! $term && ( is_tax() || is_tag() || is_category() ) ) {
$term = get_queried_object();
if ( $term ) {
$term = $term->term_id;
}
}
$description = get_term_field( 'description', $term );
return is_wp_error( $description ) ? '' : $description;
}
使用举例:
<?php echo 'Term Description: ' . term_description( '28','post_tag' ); ?>
-
WordPress函数:register_uninstall_hook 设置插件的卸载回调函数WordPress函数:register_uninstall_hook 设置插件的卸载回调函数
-
WordPress函数:wp_trash_post 移动文章到回收站WordPress函数:wp_trash_post 移动文章到回收站
-
WordPress函数:wp_update_post 更新修改文章WordPress函数:wp_update_post 更新修改文章
-
WordPress函数:wp_trash_post_comments 移动文章评论到垃圾站WordPress函数:wp_trash_post_comments 移动文章评论到垃圾站
-
WordPress函数:wp_delete_attachment 删除附件WordPress函数:wp_delete_attachment 删除评论
-
WordPress函数:wp_update_user 更新用户信息WordPress函数:wp_update_user 更新用户信息
暂无评论,抢个沙发...