我想在我的自定义模板页面上显示分类数据

问题描述:

我想在我的自定义模板页面上显示Taxonomy数据页面。我使用get_object_texonomies()功能,但我得到完整的分类数组。我想在我的自定义模板页面上显示分类数据

根据您的分类类型替换$类型

<?php 
$type = 'products'; 
$args=array(
    'post_type' => $type, 
    'post_status' => 'publish', 
    'posts_per_page' => -1, 
    'caller_get_posts'=> 1 

$my_query = null; 
$my_query = new WP_Query($args); 
if($my_query->have_posts()) { 
    while ($my_query->have_posts()) : $my_query->the_post(); ?> 
    <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> 
    <?php 
    endwhile; 
} 
wp_reset_query(); // Restore global post data stomped by the_post(). 
?> 

使用类似这样:

<?php 

    $taxonomy_objects = get_object_taxonomies('products', 'sports'); 
    print_r($taxonomy_objects); 

?> 

参考:

https://codex.wordpress.org/Function_Reference/get_object_taxonomies