Increase number of posts in archive page

Currently my website archive page is showing 5 post per page. I need to set it to 100 post per page.

(My home page showing 5 post per page and I don’t want change it)

Here is my archive.php

    <?php get_header(); ?>
    <?php do_atomic( 'before_content' ); // my-life_before_content ?>

    <div id="content">
    <?php if (have_posts()) : ?>

      <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
      <?php /* If this is a category archive */ if (is_category()) { ?>
        <h2>Archive for the &#8216;<?php single_cat_title(); ?>&#8217; Category</h2>
      <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
        <h2>Posts Tagged &#8216;<?php single_tag_title(); ?>&#8217;</h2>
      <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
        <h2>Archive for <?php the_time('F jS, Y'); ?></h2>
      <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
        <h2>Archive for <?php the_time('F, Y'); ?></h2>
      <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
        <h2>Archive for <?php the_time('Y'); ?></h2>
      <?php /* If this is an author archive */ } elseif (is_author()) { ?>
        <h2>Author Archive</h2>
      <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
        <h2>Blog Archives</h2>
      <?php } ?>

        <?php if ( is_paged() || count($posts) >= get_option('posts_per_page') ) : ?>
            <div class="post_meta archive_pagination">

                <div class="left"><?php next_posts_link('&laquo; Older Entries') ?></div>
                <div class="right"><?php previous_posts_link('Newer Entries &raquo;') ?></div>

                <div class="clearer">&nbsp;</div>

            </div>

        <?php else : ?>
        <div class="content_separator"></div>

        <?php endif;?>      

        <?php while (have_posts()) : the_post(); ?>

        <div class="archive_post">

            <div class="archive_post_date">
                <div class="archive_post_day"><?php the_time('j') ?></div>
                <div class="archive_post_month"><?php echo strtoupper(get_the_time('M')); ?></div>
            </div>

            <div class="archive_post_title">
                <h3 id="post-<?php the_ID(); ?>"><a href="https://wordpress.stackexchange.com/questions/155409/<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
                <div class="post_date">Posted in: <div class="freetory"><?php the_category(', ') ?></div> |<div class="freetory"><?php the_tags(' '); ?></div></div>
            </div>

            <div class="clearer">&nbsp;</div>

        </div>

        <?php endwhile; ?>

        <?php if ( is_paged() || count($posts) >= get_option('posts_per_page') ) : ?>

            <div class="post_meta archive_pagination">

                <div class="left"><?php next_posts_link('&laquo; Older Entries') ?></div>
                <div class="right"><?php previous_posts_link('Newer Entries &raquo;') ?></div>

                <div class="clearer">&nbsp;</div>

            </div>

        <?php endif;?>

    <?php else : ?>     
        <p>No posts found.</p>

    <?php endif; ?>
    <?php do_atomic( 'close_content' ); // my-life_close_content ?>

        <?php get_template_part( 'loop-nav' ); // Loads the loop-nav.php template. ?>

    </div><!-- #content -->

    <?php do_atomic( 'after_content' ); // my-life_after_content ?>

<?php get_footer(); // Loads the footer.php template. ?>

I’ve created the archive page via two themes “Omega” + Quietude

2

You can use pre_get_posts in your functions file to alter the query

function wpsites_query( $query ) {
if ( $query->is_archive() && $query->is_main_query() && !is_admin() ) {
        $query->set( 'posts_per_page', 100 );
    }
}
add_action( 'pre_get_posts', 'wpsites_query' );

Leave a Comment