1
맞춤형 게시물 유형과 맞춤 카테고리를 사용하고 있습니다. 페이지에서 맞춤 게시 유형의 카테고리 ID를 가져와야합니다. 다양한 방법으로 시도했지만 카테고리 ID를 가져올 수 없습니다.게시물 ID에서 Wordpress 카테고리 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를 얻을 수 없습니다입니다.