wordpress loop query to get post id and category

below i my code i am unable to get **Post id and catgory**, what i am missing please guide me for that

<

?php
    query_posts(array( 
        'post_type' => 'product',
    ) );  
     while (have_posts()) : the_post(); ?>
        <h2><?php the_title(); ?></h2>
        <p><?php echo the_content(); ?></p>
        <p>POST id:---><?php get_the_ID();?></p>
        <p>Category:---><?php get_the_ID();?></p>
        <br />--------------</br>
<?php endwhile;

Related posts

Leave a Reply

1 comment

  1. The post type, or post format, is actually a taxonomy, so you’ll have to use WP_Query to do it.

    Something along the lines of:

    <?php
    $args = array(
        'tax_query' => array(
            array(                
                'taxonomy' => 'post_format',
                'field' => 'slug',
                'terms' => 'post-format-gallery',
            )
        )
    );
    $myposts = new WP_Query( $args );
    
    if ( $myposts->have_posts() ) {
        while ( $myposts->have_posts() ) {
             $myposts->the_post();
        }
    }
    wp_reset_postdata();
    ?>