• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Custom Archive – multiple pages

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Custom Archive – multiple pages

This topic is: not resolved

Tagged: custom archive

  • This topic has 4 replies, 2 voices, and was last updated 8 years, 6 months ago by Brad Dalton.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • November 3, 2017 at 1:06 am #213210
    tatiana
    Participant

    http://tatianatsuhanish.me/the-archives/

    I created a custom archive template, and I'm pretty pleased with how it turned out. However, I would like to automatically create multiple pages, instead of infinitely scrolling. Maybe by year, so each year is its own page?

    Here is the code for my custom archive page template:

    <?php
    /**
     * Put together by Sridhar Katakam using the code linked in StudioPress forum post
     * @license GPL-2.0+
     * @link    http://www.studiopress.community/topic/creating-custom-page-templates/#post-82959
     */
    
    //* Template Name: Custom Archive
    
    //* Remove standard post content output
    remove_action( 'genesis_post_content', 'genesis_do_post_content' );
    remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
    
    add_action( 'genesis_entry_content', 'sk_page_archive_content' );
    add_action( 'genesis_post_content', 'sk_page_archive_content' );
    /**
     * This function outputs posts grouped by year and then by months in descending order.
     *
     */
    function sk_page_archive_content() {
    
    	global $post;
    	echo '<ul class="archives">';
    		$lastposts = get_posts('numberposts=-1');
    		$year = '';
    		$month = '';
    		foreach($lastposts as $post) :
    			setup_postdata($post);
    
    			if(ucfirst(get_the_time('F')) != $month && $month != ''){
    				echo '</ul></li>';
    			}
    			if(get_the_time('Y') != $year &amp;&amp; $year != ''){
    				echo '</ul></li>';
    			}
    			if(get_the_time('Y') != $year){
    				$year = get_the_time('Y');
    				echo '<li>&lt;p&gt;&nbsp;&lt;/p&gt;&lt;h1&gt;' . $year . '&lt;div class="archive-meta-out"&gt;&lt;/h1&gt;&lt;ul class="monthly-archives"&gt;&lt;div&gt;';
    			}
    			if(ucfirst(get_the_time('F')) != $month){
    				$month = ucfirst(get_the_time('F'));
    				echo '<li>&lt;h2&gt;' . $month . ' ' . $year . '&lt;/h2&gt;<ul>';
    			}
    		?&gt;
    			&lt;div class="archive-meta-out"&gt;<li>
    				&lt;?php if (function_exists('get_cat_icon')) get_cat_icon('class=avatar'); ?&gt;
    			&lt;h3 class="archive-title"&gt;<a>"&gt;&lt;?php the_title(); ?&gt;</a>&lt;/h3&gt;
    				&lt;span class="entry-meta"&gt;&lt;time class="entry-time"&gt;&lt;?php the_time('F jS, Y') ?&gt;&lt;/time&gt;&lt;/span&gt;
    				&lt;?php the_excerpt('');?&gt;
    
    
    &lt;/div&gt;
    			</li>
    		&lt;?php endforeach; ?&gt;
    		</ul>
    		&lt;?php
    }
    
    remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
    remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
    remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
    
    genesis();
    
    

    Thanks in advance for any help!

    http://tatianatsuhanish.me/the-archives/
    November 3, 2017 at 7:34 am #213218
    Brad Dalton
    Participant

    You can use a new WP_Query with the date parameters or genesis_custom_loop


    Tutorials for StudioPress Themes.

    November 3, 2017 at 7:50 am #213220
    Brad Dalton
    Participant

    Please paste the code in a Github Gist and link to it from here.


    Tutorials for StudioPress Themes.

    November 4, 2017 at 11:23 am #213260
    tatiana
    Participant

    Sorry - trying this again.

    November 4, 2017 at 11:35 am #213261
    Brad Dalton
    Participant

    You could use this code as a starting point.


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble