Community Forums › Forums › Archived Forums › Design Tips and Tricks › Custom Archive Page for Category
Tagged: archive page, category
- This topic has 4 replies, 4 voices, and was last updated 9 years, 7 months ago by
mitchb13.
-
AuthorPosts
-
February 12, 2014 at 4:34 am #89937
tribalcafe
MemberI have the following code which nicely sorts posts into date order just using titles. However I want to try to create separate archives for each category. Anybody got any ideas on how to do this amending code or pointing me in right direction.
<?php
//* 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;
$lastposts = get_posts('numberposts=-1') ;
$year = '';
$month = '';
foreach($lastposts as $post) :
setup_postdata($post);if(ucfirst(get_the_time('F')) != $month && $month != ''){
echo '';
}
if(get_the_time('Y') != $year && $year != ''){
echo '';
}
if(get_the_time('Y') != $year){
$year = get_the_time('Y');
echo '- <h2>' . $year . '</h2><ul class="monthly-archives">';
}
if(ucfirst(get_the_time('F')) != $month){
$month = ucfirst(get_the_time('F'));
echo '- <h3>' . $month . '</h3>
- ';
-
<span class="the_date"><?php the_time('d') ?>:</span>
"><?php the_title(); ?>
}?>
<?php endforeach; ?>
<?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();
April 13, 2014 at 10:48 am #100053Susan
ModeratorAs you posted this a while back, I hope you were able to get your issue resolved. If not, please check back in here, and I will escalate for you.
If it is resolved, please mark the thread “resolved”, and I will close it.
Thanks!
August 28, 2015 at 8:30 pm #163958mitchb13
MemberI saw this post and my heart jumped. Too bad this is not solved. I have been looking everywhere to learn how to simply add a page number to the title on category and tag pages. It seems to be impossible.
Anybody out there know how this is done?
August 29, 2015 at 2:03 am #163974Brad Dalton
ParticipantSeptember 8, 2015 at 7:31 pm #164982mitchb13
MemberI found the answer. I wish I could figure out where I got the code snippet from to credit it. I hacked a bit of it up to make it work the way I wanted.
The following will add "Page 2", "Page 3", and so on to index, tag, and category pages when added to functions.php.
function theme_name_wp_title( $title, $sep ) { global $page, $paged; if ( is_feed() || is_home() ) { // Add a page number if necessary: if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) { $title .= " $sep " . sprintf( __( 'Page %s', '_s' ), max( $paged, $page ) ); } return $title; } // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) { $title .= " $sep $site_description"; } // Add a page number if necessary: if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) { $title .= " $sep " . sprintf( __( 'Page %s', '_s' ), max( $paged, $page ) ); } return $title; } add_filter( 'wp_title', 'theme_name_wp_title', 10, 2 );
- <h2>' . $year . '</h2><ul class="monthly-archives">';
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.