How to show records with a list of WordPress categories ID?

I have a taxonomy which I infer records:

<?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; ?>" <!-- trying to get id column for each row -->
 <?php the_title(); ?>
</div>
 <?php } wp_reset_postdata(); ?>


I need to display the record and close the list id in which this entry resides.

To the solution was a div with the classes of each category (if more than one). Example

<div class="category-1 category-2">
Entry 1
</div>
 <div class="category-3 category-4">
Entry 2
 </div>
June 5th 19 at 21:28

Find more questions by tags WordPress