简体   繁体   中英

Adding number of posts to custom post archive page.

I am using Wordpress and the Roots Template. I have created an archive page to show member profiles. - its just index.php saved out as archive-members.php so it gets the member posts, but I don't know how to change the number it displays. I want it to display all. its not using any custom post type query, its just an archive of this post-type slug

Here is my page code.

    <div class="purple row">
  <div class="container">
    <div class="col-lg-12">
      <?php get_template_part('templates/page', 'header'); ?>
    </div>
  </div>
</div>

<?php if (!have_posts()) : ?>
  <div class="alert alert-warning">
    <?php _e('Sorry, no results were found.', 'roots'); ?>
  </div>
  <?php get_search_form(); ?>
<?php endif; ?>

<div class="row pagecontent">
  <div class="container">
    <?php while (have_posts()) : the_post(); ?>
    <div class="col-sm-3">
      <?php get_template_part('templates/members', get_post_format()); ?>
    </div>

  <?php endwhile; ?>

  <?php if ($wp_query->max_num_pages > 1) : ?>
</div>
</div>

  <div class="container">
    <div class="col-lg-12">
       <nav class="post-nav">
    <ul class="pager">
      <li class="next"><?php next_posts_link(__('Next Page &rarr;', 'roots')); ?></li>
      <li class="previous"><?php previous_posts_link(__('&larr; Previous Page', 'roots')); ?></li>
    </ul>
  </nav>
    </div>
  </div>


<?php endif; ?>

I believe this question has already been answered here.

The answer in that thread links to the WordPress codex on using the query_post() function.

That, or as someone else in the thread states, you can try changing the settings in the admin interface (settings -> reading). There, you'll see a box that allows you to change how many posts are displayed on a page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM