Php wordpress更新4.8.2后代码停止工作
我尝试使用提供的代码,但仍然不起作用。。。 它只是在升级到wordpress 4.8.2之后才开始出现问题 我还复制了以下部分的代码,其中我关闭了foreach和if。。。 使用Wordpress 4.7.6可以完美地工作。。。 有什么想法吗? 非常感谢你的帮助Php wordpress更新4.8.2后代码停止工作,php,wordpress,Php,Wordpress,我尝试使用提供的代码,但仍然不起作用。。。 它只是在升级到wordpress 4.8.2之后才开始出现问题 我还复制了以下部分的代码,其中我关闭了foreach和if。。。 使用Wordpress 4.7.6可以完美地工作。。。 有什么想法吗? 非常感谢你的帮助 <?php $cat_array = array(); $args = array( 'post_type' => 'post', 'pos
<?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();
?>
使用
'ignore\u sticky\u posts'
而不是'caller\u get\u posts'
。
您可以参考更新查询使用
'ignore\u sticky\u posts'
而不是'caller\u get\u posts'
。
您可以参考更新您的查询我不知道您的要求,但我认为您没有关闭foreach循环和if条件,而且我认为您需要为您应该使用的职位分配类别的高级自定义字段值
wp_get_post_categories( int $post_id, array $args = array() )
在你的while循环中。希望这有帮助
您应该使用“忽略粘贴帖子”而不是“调用者获取帖子”我不知道您的要求,但我认为您没有关闭foreach循环和if条件,而且我认为您需要为帖子分配类别的高级自定义字段值,以便您使用
wp_get_post_categories( int $post_id, array $args = array() )
在你的while循环中。希望这有帮助
您应该使用“忽略粘性帖子”而不是“调用者获取帖子”使用下面的代码
<?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);
}
}
?>
享受使用下面的代码
<?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);
}
}
?>
享受