0

I've created a showcase template part that will get all my custom post_type for a showcase. The problem is that I've 18 entries added and the template part will only show 10 entries. I've used a bootstrap modal to obtain a gallery effect, and it is generated inside the foreach loop that display the gallery attachments inside the modal, this will cause that every entry has a modal. I don't think that the problem is this, but here is my code, can everyone suggest me a fix for this?

<div class="row">
  <div class="col-sm-12 col-md-12 col-lg-12 text-center" id="title-col">
    <h1 class="display-4 text-center text-uppercase"><?php _e('Showcase') ?></h1>
    <p class="lead text-center"><?php _e('lorem ipsum') ?></p>
  </div>
<?php
$args = array(
  'post_type' => 'showcase'
);
$showcase = new WP_Query( $args );
?>
<?php if( $showcase->have_posts() ): while( $showcase->have_posts() ): $showcase->the_post(); ?>
  <div class="col-sm-12 col-md-3 col-lg-3" id="showcase-col">
  <a class="open-modal" data-target="#showcaseModal-<?php echo get_the_ID();?>" data-toggle="modal">
    <div class="card">
      <img class="card-img-top" src="<?php the_post_thumbnail_url('full'); ?>" alt="<?php the_title(); ?>" id="">
      <div class="overlay">
        <p class="lead text-center ovl"><i class="fas fa-search-plus"></i></p>
        <h4 class="text-center"><?php the_title(); ?></h4>
        <?php the_content(); ?>
      </div>
    </div>
  </a>
  </div>

<!-- Modal -->
<div class="modal fade" id="showcaseModal-<?php echo get_the_ID(); ?>" tabindex="-1" role="dialog" aria-labelledby="ProductShowcaseModal" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel"><?php the_title(); ?></h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <img class="img-responsive w-100" src="<?php the_post_thumbnail_url('full'); ?>">
      </div>
    </div>
  </div>
</div>

<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
</div>
  • 2
    You don’t specify how many posts you want returned, so it defaults to whatever you set posts_per_page to in your settings. – Milo Feb 11 at 19:20
  • so I need to set -1 as the post_per_page value to return all? If I want to do a show all link, I need to use ajax with pagination or what? – ZWPDev Feb 11 at 19:27
  • @Milo If I load all posts using -1, how I can add a show more link? – ZWPDev Feb 11 at 20:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.