Answer the question
In order to leave comments, you need to log in
How to display WordPress posts with a list of their category IDs?
I have a taxonomy for which I display posts:
<?php
global $post;
$args = array('numberposts' => -1, 'post_type' => 'catalog-object');
foreach( $myposts as $post ){ setup_postdata($post);
$getcat = get_the_category(); ?>
<div class="category-<?php echo $cat->term_id; ?>"
<!-- пытаюсь получить ID рубрики у каждой записи -->
<?php the_title(); ?>
</div>
<?php } wp_reset_postdata(); ?>
<div class="category-1 category-2">
Запись 1
</div>
<div class="category-3 category-4">
Запись 2
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question