所以我正在做一个网站,遇到了一个自定义帖子类型显示的问题。基本上,我有一个名为resource的post类型。这些资源分为三个不同的类别,用于统计、用于非统计和临床。
这是资源帖子编辑页面的样子。
正如你所看到的,在底部有一个下拉菜单,用户可以决定观众。下面是我用来将资源页面上的资源排序到各个部分的代码。
<?php $args = array(
'post_type' => 'resource',
'order' => 'ASC');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$resource_type = get_field('resource_type');
$audience = get_field('audience');
$forStat = "For Statisticians";
$notForStat = "For Non-Statisticians";
$clinical = "Clinical Trials";
$hasLink = FALSE;
if (get_field(resource_link)){
$hasLink = TRUE;
$resource_link = get_field('resource_link');
} else {
$resource = get_field('resource');
}
?>
<?php if ($audience == $forStat) { ?>
<?php if ($hasLink) { ?>
<a href="<?php echo $resource_link; ?>"><button type="button" class="list-group-item"><?php the_title(); ?></button></a>
<?php } else {
$resourceUrl = $resource['url']; ?>
<a href="<?php echo $resourceUrl; ?>"><button type="button" class="list-group-item"><?php the_title(); ?></button></a>
<?php } ?>
<?php } ?>
<?php endwhile;?>
这里是资源页面,所以你可以看到,即使有16个统计学家的资源,也只显示了10个帖子。The website resource page.
你知道为什么只显示了我制作的前10个资源吗?
发布于 2016-07-14 15:38:09
添加
'posts_per_page' => -1,
作为参数。
$args = array(
'post_type' => 'resource',
'order' => 'ASC',
'posts_per_page' => -1
);
https://stackoverflow.com/questions/38378391
复制相似问题