カスタム投稿タイプとカスタムカテゴリを使用しています。ページ内のカスタム投稿タイプのカテゴリIDを取得する必要があります。いろいろな方法で試してみましたが、カテゴリIDが取得できません。
<?php
$args = array(
'posts_per_page'=> -1,
'post_type' => 'professional',
'orderby'=> 'id',
'order'=> 'asc',
);
query_posts($args);
$my_posts = new WP_Query($args);
while ($my_posts->have_posts()) : $my_posts->the_post(); // loop for posts
function getCurrentCatID(){
global $wp_query;
global $post;
$cats = get_queried_object()->term_id;
$cat_ID = $cats[0]->cat_ID;
return $cat_ID;
}
?>
<li>
<div class="caption">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<span class="industry"><?php getCurrentCatID($cat_ID); ?></span>
</div>
</li>
カスタム投稿タイプで猫IDを取得できません。