Php 为什么我的16篇文章中只有10篇被显示?
因此,我正在制作一个网站,并遇到了一个问题的自定义帖子类型正在显示。基本上,我有一个帖子类型叫做resource。这些资源分为三个不同的类别,统计、非统计和临床 以下是资源后期编辑页面的外观。 如您所见,底部有一个下拉菜单,供用户决定受众。下面是我用来将资源页面上的资源分类为各个部分的代码Php 为什么我的16篇文章中只有10篇被显示?,php,wordpress,wordpress-theming,Php,Wordpress,Wordpress Theming,因此,我正在制作一个网站,并遇到了一个问题的自定义帖子类型正在显示。基本上,我有一个帖子类型叫做resource。这些资源分为三个不同的类别,统计、非统计和临床 以下是资源后期编辑页面的外观。 如您所见,底部有一个下拉菜单,供用户决定受众。下面是我用来将资源页面上的资源分类为各个部分的代码 <?php $args = array( 'post_type' => 'resource', 'order' => 'ASC'); $loop = new WP_Query( $a
<?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;?>
这里是资源页面,所以你可以看到只有10个帖子被显示,尽管有16个统计人员的资源
你知道为什么只显示我制作的前10个资源吗?添加
'posts_per_page' => -1,
作为一个参数
$args = array(
'post_type' => 'resource',
'order' => 'ASC',
'posts_per_page' => -1
);
加
作为一个参数
$args = array(
'post_type' => 'resource',
'order' => 'ASC',
'posts_per_page' => -1
);
您(或您的框架)如何管理分页?您(或您的框架)如何管理分页?