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

我想在wordpress的自定义模板页面上显示分类数据,wordpress,taxonomy,custom-taxonomy,Wordpress,Taxonomy,Custom Taxonomy,我想在我的自定义模板页面上显示分类法数据 我使用了get\u object\u texonomies()函数,但我得到了完整的分类数组 根据您的分类类型替换$type <?php $type = 'products'; $args=array( 'post_type' => $type, 'post_status' => 'publish', 'posts_per_page' => -1, 'caller_get_posts'=> 1 $my_qu

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


我使用了
get\u object\u texonomies()
函数,但我得到了完整的分类数组

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

<?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);

?>

参考资料: