如何从用户正在浏览的当前自定义分类法(类别)中获取ID?
它使用一种称为“产品”的自定义帖子类型,这些类别称为“pcategories”
对于普通类别,我会得到如下结果:
<?php if ( is_category() )
{
$cat= get_category( get_query_var( \'cat\' ) );
$cat_id = $cat->cat_ID;
$categorytable = myrp_api_comparison_table( $category = $cat_id, $number = null, $visit_text = "Visit Text", $image_set = null, $custom_fields = null, $rating_categories = null, $return = false );
if(empty($categorytable))
{} else
{
echo $categorytable;
}
}
?>
那么,如何使用自定义分类法来实现这一点呢?
如果我这样做:
<pre><?php print_r($wp_query->query_vars); ?></pre>
我得到:
Array
(
[pcategory] => televisies
[error] =>
[m] => 0
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[comments_popup] =>
[meta_key] =>
[meta_value] =>
[preview] =>
[s] =>
[sentence] =>
[fields] =>
[category__in] => Array
(
)
[category__not_in] => Array
(
)
[category__and] => Array
(
)
[post__in] => Array
(
)
[post__not_in] => Array
(
)
[tag__in] => Array
(
)
[tag__not_in] => Array
(
)
[tag__and] => Array
(
)
[tag_slug__in] => Array
(
)
[tag_slug__and] => Array
(
)
[ignore_sticky_posts] =>
[suppress_filters] =>
[cache_results] => 1
[update_post_term_cache] => 1
[update_post_meta_cache] => 1
[post_type] =>
[posts_per_page] => 10
[nopaging] =>
[comments_per_page] => 50
[no_found_rows] =>
[taxonomy] => pcategory
[term] => televisies
[order] => DESC