Php 在基于自定义参数的Wordpress循环中未找到帖子
我在args数组中设置了一个simply参数,但没有通过任何适当的POST 通过使用高级自定义字段,我在“post”类型中创建了一个“Select”选项,该选项为“Featured:Yes”。大约有4篇文章被设置为特色文章,但仍然没有找到文章 **我提供了该页面的屏幕截图。正如您将看到的,在页面的下半部分有一些帖子是使用标准循环来完成的,但是我已经设置了一个新的循环,只在顶部显示特色帖子。也许我应该先结束全球循环 以下是我当前的设置:Php 在基于自定义参数的Wordpress循环中未找到帖子,php,wordpress,Php,Wordpress,我在args数组中设置了一个simply参数,但没有通过任何适当的POST 通过使用高级自定义字段,我在“post”类型中创建了一个“Select”选项,该选项为“Featured:Yes”。大约有4篇文章被设置为特色文章,但仍然没有找到文章 **我提供了该页面的屏幕截图。正如您将看到的,在页面的下半部分有一些帖子是使用标准循环来完成的,但是我已经设置了一个新的循环,只在顶部显示特色帖子。也许我应该先结束全球循环 以下是我当前的设置: <?php // args $args = arr
<?php
// args
$args = array(
'numberposts' => -1,
'meta_key' => 'feature_post',
'meta_value' => 'Yes'
);
// get results
$the_query = new WP_Query( $args );
// The Loop
?>
<?php if( $the_query->have_posts() ): ?>
<ul class="bxslider">
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li>
<div class="featured-article">
<div class="category-label">Health</div>
<i class="category-label-end"></i>
<?php echo the_post_thumbnail(); ?>
<div class="featured-article-title">
<h2><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h2>
</div>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php else : echo '<p style="color:#fff;">no posts</p>'; ?>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
高级自定义字段
已设置为“特色”的帖子
帖子页面:
我怀疑这是因为在一个字段中可以有多个复选框,这意味着ACF需要将值存储为数组,而不是单个字符串 我刚刚做了一个测试,这是根据您的设置得到的
meta\u值:
a:1:{i:0;s:3:"Yes";}
它与您正在使用的文本Yes
不匹配
在这种情况下,我会尝试使用ACF的True/False
字段类型。如果为true,它将1
存储在meta_value
字段中,这将与您正在使用的方法一起工作。Hi,首先是numberposts=>-1
?,@Mauro-这意味着返回所有行(不限制/分页查询)好的,是的,true/False字段类型起了作用,所以我现在继续。谢谢