Я намагаюся завантажити всі зображення з повідомлень у cat 5 у таксономії gallery_Category, яку я створив. Ніщо не працює, і я не можу зрозуміти, чому ні.
<?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 } ?>
Відповіді:
1 для відповіді № 1<?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();
}
}
?>
спробуйте це
також посилайтеся тут