【发布时间】:2018-09-28 17:22:11
【问题描述】:
所以我想返回一个只返回一个类别的 Wordpress 循环,所以目前我有这样的东西
<?php query_posts('cat=5'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
这很好用,完全符合我的要求
但我希望由 ACF 设置类别编号,所以我进行了设置,它在网站上将我的值作为字符串返回,一切都很好,所以现在我的代码看起来像这样
<p>My category number is - <?php the_field('category_number'); ?></p>
<?php query_posts('cat=5'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
我想做的是这样的
<p>My category number is - <?php the_field('category_number'); ?></p>
<?php query_posts('"cat=", the_field("category_number")'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
我不认为我正在以正确的方式解决这个问题,并且似乎无法找到答案,因为我认为我不是在寻找正确的东西..如果有人可以指出我正确的方向,我真的很感激
【问题讨论】:
标签: wordpress advanced-custom-fields