Php WP_查询:按标签返回帖子,按帖子格式过滤
我有以下代码片段,应该返回6篇与当前post by标记相关的文章,这6篇文章应该是具有video post格式分类的文章:Php WP_查询:按标签返回帖子,按帖子格式过滤,php,logical-operators,wordpress,Php,Logical Operators,Wordpress,我有以下代码片段,应该返回6篇与当前post by标记相关的文章,这6篇文章应该是具有video post格式分类的文章: if('artists' == get_post_type()){ $taxs = wp_get_post_tags($post->ID); $name = the_title(); if($taxs){ $tax_ids = array(); foreach ($tax_ids as $individual_t
if('artists' == get_post_type()){
$taxs = wp_get_post_tags($post->ID);
$name = the_title();
if($taxs){
$tax_ids = array();
foreach ($tax_ids as $individual_tax){
$tax_ids[] = $individual_tax->term_id;
}
gs = array(
'post_type' =>'post',
'tag__in'=> $tax_ids,
'tax_query' =>array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array('post-format-video')
),
),
'post__not_in' => array($post->ID),
'posts_per_page' => 6,
'ignore_sticky_posts' => 1,
);
$video_query = new WP_QUERY($args);
// other code comes here .........
问题是,当我运行查询时,它会返回所有具有video post格式的帖子,而不是那些具有相关标记作为当前正在查看的帖子的帖子。请帮我解决这个问题
让我举个例子:当前帖子有一个名为“oranges”的标签。在相关文章部分,我想让它显示同样有一个名为oranges的标签的文章,但只显示那些具有video post格式分类的文章 您的foreach循环应该是:
foreach ($taxs as $individual_tax)
而不是:
foreach ($tax_ids as $individual_tax)
中的标记应为标记__in@PieterGoosen谢谢我已经纠正了拼写错误,但仍然没有按预期工作。Yeeeeees:-按照说明进行了更改,并且工作正常。都是些小事