php 获取自定义分类分类当前id标记当前id
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 获取自定义分类分类当前id标记当前id相关的知识,希望对你有一定的参考价值。
function current_id_for_color()
{
global $wp_query;
global $pos;
$current_id = get_the_ID();
if( is_home() ){
$current_id = get_option( 'page_for_posts' );
}elseif( is_tax() ){
$value = $wp_query->query_vars['taxonomy'];
$current_term = get_term_by( 'slug', $wp_query->query_vars[$value], $value );
$current_id = $value.'_'.$current_term->term_id;
}elseif( is_tag() ){
$current_term = get_term_by( 'slug', $wp_query->query_vars['tag'], 'post_tag' );
$current_id = 'post_tag_'.$current_term->term_id;
}
return $current_id;
}
以上是关于php 获取自定义分类分类当前id标记当前id的主要内容,如果未能解决你的问题,请参考以下文章