0
我想在我的自定義模板頁面上顯示Taxonomy
數據頁面。我使用get_object_texonomies()
功能,但我得到完整的分類數組。我想在我的自定義模板頁面上顯示分類數據
我想在我的自定義模板頁面上顯示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