문제

I am trying to load all the images from posts in cat 5 within the gallery_Category taxonomy I created. Nothing is working and I can't see why not.

<?php

            $args = array(
                    'post_type' => 'post',
                    'taxonomy' => 'gallery_category',
                    'term_id' => '5'
            );
            $query = new WP_Query($args);
            while ($wp_query->have_posts()) {
               $wp_query->the_post();
                ?>
               <?php the_post_thumbnail(); ?>
        <?php } ?>
도움이 되었습니까?

해결책

<?php

$args = array(
    'post_type' => 'post',
    'tax_query' => array(
        array(
            'taxonomy'  => 'gallery_category',
            'field'     => 'slug',
            'terms'     => '5'
        )
    )
);

$my_query = new WP_Query($args);
while ($my_query->have_posts()) {
$my_query->the_post();

  if ( has_post_thumbnail()) {
    the_post_thumbnail();
  } 

 } 
?>

try this

also do refer here

wp query

wordpress loop

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top