Update on May 27, 2017: A newer and simpler version (slightly different output) here > https://sridharkatakam.com/group-entries-month-year-cpt-archive-genesis/
When Archive Template is applied to a Page in Genesis, all pages, categories, authors, monthly archives, and recent posts will be displayed like this.
In this article I share the code that makes available a Custom Archive Template which when applied to a Page will display posts grouped by year and then by months with published date before each post, in descending order.
Create a file named page_custom_archive.php in your child theme having the following code:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.
Great post! How can you do the same thin but instead of date and year, display a catagory and list it from a-b-c etc. I want to make a dictionary list, and start by letter a.
Great tutorial! If I would like to add also the categories and the tags under it would it be possibile? Thanks!!!
You mean showing categories and tags beneath each post or totally at the bottom of posts list?
I mean a list of categories, tags and pages like in the regular genesis archive
Sridhar, how can I exclude a single category, let’s say category 100, from the archives list using your code?
Thanks!
I also would like to remove a specific category from showing up in archive list.
any help would be great
Wonderful stuff.
Encountered a minor problem:
When the final posts displayed for a certain year occur in the same month as the first posts for the previous year, the code doesn’t output the month. It also displays the year for the previous year at the incorrect list level.
Example test case:
2013
November
October
September
2012
September
Was able to correct this by replacing the existing conditional at approximately line 36 with the following code:
if (get_the_time('Y') != $year) {
$year = get_the_time('Y');
if (ucfirst(get_the_time('F')) == $month) {
echo '';
echo '' . $year . '';
echo '' . $month . '';
}
else
echo '' . $year . '';
}
This may not be most elegant solution given the code structure but does appear to work.
Thanks
I was wondering, trying to figure out a code so that pagination starts say like after every two years so the page doesn’t go on and on. Can that be done? Thank you!!
When I use this code it forced the comment box to appear below the archive list. How can I remove remove the comment box?
Yep, having the comments box at the bottom of this page isn’t great. Even when deselecting the check box on the page settings doesn’t work, as you say the code forces the comments box to appear.
@Sridhar, any information on how to remove the comments box would be useful – thanks.
How can I recreate the problem? With a fresh WordPress, latest Genesis parent and Sample child themes I don’t get the comments box.
Which child theme are you guys using?
Hi, VERY happy with your custom archive page template. I am using WP 4.0.1 and Genesis ChildTheme Expose Pro.
2 Questions:
1. I like to add Categories or better put: I just do not want pages in my archive as I have a lot of landing pages which makes the archive long and I do not want them to be shown. Just Categories (I have about 8) and then followed by Posts as in your template.
2. I do not want the ul and li things. Just everything on the utter left (align: left ??). On a mobile phone you have a lot of white space. Tried your CSS (Metro Pro) but does not work on Expose Pro apparently.
thx a lot in advance
You are my new favourate person! Thanks I was looking for this. Its a lot like the archive at ZenHabits.net which I love.
Hello, Please any idea to add Pagination? Because I published post every day of the month, and it’s making the archive page very long
Sridhar, really love this styling for listing posts. How would use use the same format to list specific categories in different sections on the page?
Hey Sridhar,
How would I reverse the order here? So, ascending instead of descending. I’d like oldest posts to be at the top. Does that make sense?
Thanks.
I also would like to remove a specific category from showing up in archive list.
any help would be great
Hey Greg – you can exclude a category by following Bill Erickson’s tutorial – http://www.billerickson.net/customize-the-wordpress-query/
If you’re using the code in this tutorial as archive.php you’d to use is_archive instead of is_home. If you’re using this code as a page template, like Sridhar does in this example, you’s probably need to use the page ID – like is_page( $ID ) – and put the page id # in place of $ID.
Hope that helps.
Hello,
this code would be great for me but it doesn’t work… I don’t know what I wrong…
I use Lifestyle Pro Theme.
I createda page_custom_archive.php and uploaded it in the Lifestyle theme folder.
I created a new page with the new Custom Archive Template.
When I click on the Archive Menu I have a blank page with this message:
Parse error: syntax error, unexpected T_STRING in /home/musichi9/public_html/wp-content/themes/lifestyle-pro/page_custom_archive.php on line 9
Any suggestion?
Thank you very much
Gianmaria
Hey Gianmaria,
I have the Lifestyle Pro theme and used Sridhar’s code and it worked fine for me. Let me tell you exactly what I did and you can see if you did anything different:
-I made a copy of my functions.php file, then I changed the name to page_custom_archive.php
-Within textedit, I deleted everything on the page. Then I clicked the ‘view raw’ button at the bottom of Sridhar’s code, copied the entire code and pasted it onto this new archive page within textedit.
-I used my FTP software, opened up my lifestyle pro theme and just added the page within the theme.
-Lastly, I went into my theme in wordpress and created a page. Under templates on the right, a new option was there called Custom Archive. I selected that, added the page to my menu and the page looks pretty much exactly like Sridhar’s, before I even messed with the CSS.
Hope this helps!
And Sridhar, thank you so much for this code, and for all your tutorials! I have used several of your examples and find your site to be absolutely invaluable!
-Kelly
Did you have to add anything to the functions.php to get the page_archives.php that comes with Genesis to work?
mine will not load and I can’t figure out what’s wrong. I’ve tried registering the post type in functions.php, but that doesn’t work.
I can’t seem to figure out what the archives post template doesn’t work out of the box.
Hi, thank you for another helpful post!
I have a question that is related. I used this post and another similar to make archives.
I created a special archive that should show all posts from a certain category, but it is only showing the most recent 5 posts.
Could you take a look at the code and see if you have a thought as to why that may be?
For reference, the page can be seen here: Investment Archive
I appreciate it!
————————————————–
<a href="”>
Posted on
<?php
}
genesis();
Somehow my code got messed up. Here it is again:
<a href="”>
Posted on
<?php
}
genesis();
I would really love it to be able to paginate. 🙂
Hey Sridhar,
I would love to remove the pagination from the bottom of the custom archive page only. How do I do this? I’ve tried playing it with my localhost site, however, I can’t seem to remove the pagination from the bottom.
I am using the Daily Dish Pro theme, if that makes a difference.
Thanks, I appreciate everything you do.
Susan
Hi Sridharkatakam,
this code doesn´t work. It shows 3 times the loop. Do you know why?
Please follow https://sridharkatakam.com/group-entries-month-year-cpt-archive-genesis/ instead of this tutorial.