Reputation: 199
So I am making a website and ran into a problem of a custom post type being shown. Basically, I have a post type called resource. The resources are sorted into three different categories, For Stats, For Non-Stats, and Clinical.
Here is what the resource post editing page looks like. As you can see, at the bottom there is a dropdown menu at the bottom for the user to decide the audience. Here is the code I'm using to sort the resources on the resource page into the individual sections.
<?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;?>
Here is the resource page so you can see that only 10 posts are being shown even though there are 16 resources For Statisticians. The website resource page.
Any ideas why only the first 10 resources that I made are being shown?
Upvotes: 0
Views: 53
Reputation: 630
Add
'posts_per_page' => -1,
as a parameter.
$args = array(
'post_type' => 'resource',
'order' => 'ASC',
'posts_per_page' => -1
);
Upvotes: 2