Reputation: 740
I've been bugging about this issue for days now so hope to find a solution here.
I'm trying to display data coming from a Custom Field Group. Here's a sample layout of what I'm trying to achieve
Basically, I'm trying to display 20++ of those columns. However, I'm only getting about 11 coming from this custom field group.
Here's my code for the template of the page:
<?php
/* Template Name: Branches Page */
get_header();
global $currentCity;
$registration_link = get_post_meta(96, 'registration_link', true);
$registration_text = get_post_meta(96, 'registration_text', true);
$thumbnail_url = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
?>
<!-- FEATURE IMAGE
================================================== -->
<?php if( has_post_thumbnail() ) { // check for feature image ?>
<section class="feature-image" style="background: url('<?php echo $thumbnail_url; ?>') no-repeat; background-size: cover;" data-type="background" data-speed="2">
<h1 class="page-title"><?php the_title(); ?></h1>
</section>
<?php } else { // fallback image ?>
<section class="feature-image feature-image-default" data-type="background" data-speed="2">
<h1 class="page-title"><?php the_title(); ?></h1>
</section>
<?php } ?>
<!-- MAIN CONTENT
================================================== -->
<div class="container">
<div class="row" id="primary">
<div id="content" class="col-sm-12>
<section class="main-content">
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; // end of the loop ?>
<?php $loop = new WP_Query( array( 'post_type' => 'branches_locations', 'orderby'=>'post_id', 'order'=>'ASC' ) ); ?>
<div class="resource-row clearfix">
<?php while( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
$resource_url = get_field('resource_url');
$address = get_field('address');
$city = get_field('city');
$branch_image = get_field('branch_image');
$senior_high_ready = get_field('senior_high_ready');
?>
<div class="resource">
<?php
if( $city <> $currentCity )
{
?>
<h2>
<?php echo $city; ?>
</h2>
<?php
}
else
{
?>
<h2 class="hidden-dummy-header">
Blank
<h2>
<?php
}
?>
<h3><?php the_title(); ?></h3>
<p><?php echo $address; ?></p>
<?php
if( $senior_high_ready == True)
{
?>
<h5 class="senior_high_ready">
SENIOR HIGH READY
</h5>
<?php
}
else
{
?>
<h5 class="hidden-dummy-header">
Blank
</h5>
<?php
}
?>
<img src="<?php echo $branch_image[url]; ?>" alt="<?php echo $branch_image[alt]; ?>">
<div class="register-link">
<a href="<?php echo $registration_link; ?>" class="btn btn-primary"><?php echo $registration_text; ?>
</a>
</div>
<?php $currentCity = $city; ?>
</div><!-- resource -->
<?php endwhile; ?>
</div><!-- resource-row -->
</section><!-- main-content -->
</div><!-- content -->
</div><!-- row -->
</div><!-- container -->
<?php get_footer(); ?>
What is causing it not to display the entire list on my custom field group?
Upvotes: 1
Views: 225
Reputation: 430
By default, WordPress sets posts_per_page to 10, so you only get 10 at a time, unless the default is changed somewhere else in your code. You can get all posts by setting it to -1. Like this:
<?php $loop = new WP_Query( array( 'posts_per_page' => -1, 'post_type' => 'branches_locations', 'orderby'=>'post_id', 'order'=>'ASC' ) ); ?>
I hope that helps!
Also, you can break that into multiple lines to improve readability, for example:
<?php
$loop = new WP_Query( array(
'posts_per_page' => -1,
'post_type' => 'branches_locations',
'orderby'=>'post_id',
'order'=>'ASC'
) );
?>
BTW, I'd refer to it as a custom post type rather than a custom field group. (Just for future reference, as you might get better google search results if you use that term.)
Upvotes: 2