私は提供されたコードで試しましたが、動作しません... そしてそれはWordPress 4.8.2にアップデートした後にのみ問題を提起し始めました。 私はまた私はforeachとifを閉じるparteの後に... Wordpress 4.7.6で完璧に動作します... 任意のアイデア? ありがとうございました!WordPressの更新後にコードが機能しなくなった4.8.2
<?php
$cat_array = array();
$args = array(
'post_type' => 'post',
'posts_per_page' => 9,
'ignore_sticky_posts' => 1
);
$my_query = null;
$my_query = new WP_Query($args);
if ($my_query->have_posts())
{
while ($my_query->have_posts()):
$my_query->the_post();
$cat_args = array(
'orderby' => 'none'
);
$cats = wp_get_post_terms($my_query->post->ID, 'category', $cat_args);
foreach($cats as $cat)
{
$cat_array[$cat->term_id] = $cat->term_id;
}
endwhile;
wp_reset_postdata();
}
if ($cat_array)
{
foreach($cat_array as $cat)
{
$category = get_term_by('ID', $cat, 'category');
$slug = get_term_link($category, 'category');
$id = $category->term_id;
$valore = "category_" . $id;
$colore = get_field('colore_categoria', $valore);
$immagine = get_field('immagine_ispirazione', $valore);
$testo_box = get_field('testo_box', $valore);
?>
<div class="colonna clearfix">
<a href="<?php echo $slug;?>">
<div class="box">
<img src="<?php echo $immagine?>" alt="italia">
<div class="overlay">
<p><?php echo $testo_box;?></p>
</div>
<div class="titolobox" style="background-color:<?php echo $colore;?>">
<h2><?php echo $category->name;?></h2>
</div>
</a>
</div>
</div>
<?php
}
}
wp_reset_query();
?>
を楽しむ:( –