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 6 years, 4 months ago by Brad Dalton.
Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
November 3, 2017 at 1:06 am #213210tatianaParticipant
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 && $year != ''){ echo '</ul></li>'; } if(get_the_time('Y') != $year){ $year = get_the_time('Y'); echo '<li><p> </p><h1>' . $year . '<div class="archive-meta-out"></h1><ul class="monthly-archives"><div>'; } if(ucfirst(get_the_time('F')) != $month){ $month = ucfirst(get_the_time('F')); echo '<li><h2>' . $month . ' ' . $year . '</h2><ul>'; } ?> <div class="archive-meta-out"><li> <?php if (function_exists('get_cat_icon')) get_cat_icon('class=avatar'); ?> <h3 class="archive-title"><a>"><?php the_title(); ?></a></h3> <span class="entry-meta"><time class="entry-time"><?php the_time('F jS, Y') ?></time></span> <?php the_excerpt('');?> </div> </li> <?php endforeach; ?> </ul> <?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 #213218Brad DaltonParticipantYou can use a new WP_Query with the date parameters or genesis_custom_loop
November 3, 2017 at 7:50 am #213220Brad DaltonParticipantNovember 4, 2017 at 11:23 am #213260tatianaParticipantSorry - trying this again.
November 4, 2017 at 11:35 am #213261Brad DaltonParticipant -
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.