【发布时间】:2012-12-05 14:07:40
【问题描述】:
在 Wordpress 网站上工作,想知道是否有人能指出我正确的方向。 我有以下 query_post 过滤我模板上的帖子并且效果很好。
query_posts( array( 'category_name' => 'galoretv', 'post_type' => 'post', 'paged'=>$paged, 'showposts'=>0, ) );
如何附加此内容以包括对高级自定义字段中特定值的检查? 此类别中的帖子有一个单选按钮,其中包含三个选项“主要”“次要”“标准” 我希望能够检查每个值,即如果您属于“galoretv”和“标准”,请执行此操作。
我使用上面的参数执行和排序页面,只是不确定如何添加 ACF 值。我能够使用粘性选项让它工作,但这会起作用,因为我需要有主要和次要的可选性。这是我用粘性的节目。
query_posts( array( 'category_name' => 'galoretv', 'post_type' => 'post', 'paged'=>$paged, 'showposts'=>0, 'post__in'=>get_option('sticky_posts')) );
单选按钮字段称为“landing-grid-placement”
有什么想法吗?查了文档,没搞清楚。 http://www.advancedcustomfields.com/docs/field-types/checkbox/
以为这样可以,但是没有
query_posts( array( 'category_name' => 'galoretv', 'post_type' => 'post', 'paged'=>$paged, 'showposts'=>0, 'landing-grid-placement' => 'primary') );
任何帮助将不胜感激。这可能是一个简单的语法问题,但它让我无法理解并给我带来了很多问题。一直在寻找答案,但还没有得到正确的答案。提前感谢阅读本文的人,并再次感谢任何提供解决方案的人。
以下每条注释的附加代码
<?php
$args = array(
'post_type' => 'post',
'category-slug' => 'models-galore',
'showposts'=>1,
'meta_query' => array(
array(
'key' => 'grid_location',
'value' => 'primary',
'compare' => '=',
'type' => 'CHAR'
)
)
);
$query = new WP_Query($args);
if($query->have_posts()) {
while($query->have_posts()) {
$query->the_post();
?>
<li class="span8">
<div class="thumbnail">
<a href="<?php echo get_permalink(); ?>"><?php echo get_the_post_thumbnail( get_the_ID(), 'media-large-thumb' ); ?></a>
<h3>
<a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a>
</h3>
</div>
</li>
<?php
}
}
?>
【问题讨论】:
标签: arrays wordpress custom-fields posts