wordpress在文章页面获取所属分类的id两种可用的方法
方法一、二
//wordpress 根据文章ID获取分类ID $category=get_the_category( $post_ID ); $catid=$category[0]->term_id; //wordpress 根据文章ID获取标签ID $tags=wp_get_post_tags( $post_ID ); $tagid=$tags[0]->term_id;方法三:
foreach((get_the_category()) as $category) { echo $category->cat_ID . ' '; //当前文章的分类的ID echo $category->cat_name . ' '; //当前文章的分类的名称 }
转载请注明出处: 沐辰客栈
本文的链接地址: https://qqm90.cn/wordpress/473.html
上一篇
wpog协议
您可能对以下文章感兴趣
发表评论 取消回复