WordPress Archive Tutorial (archive.php)

WordPress Archive Tutorial (archive.php)

In this lesson we add a new file named “archive.php” to our theme folder and learn how to control the title text that is displayed for different types of archive listings (category, author, date). Check out my “Get a Developer Job” course:

To view a complete list of the WordPress lessons in sequential order visit:

Link to download .zip of theme files as shown in this video (note: this is not a “complete” WordPress theme yet and this download is only intended for educational purposes to dissect and review):

Want to share the WordPress website that you’ve been creating on your computer with the world? Learn about the web host I use and how you can get a domain + hosting for .95 a month ( savings):

Sign up for my newsletter to receive periodic webDev tips, tricks, resources and coupons. Join the list at

Follow LearnWebCode on Twitter for resources and updates:


30 Replies to “WordPress Archive Tutorial (archive.php)”

  1. Can someone help me? For some reason, when I change the settings to “Month and name” and click “View your site” it send me to “Not found”…

  2. +LearnWebCode  I have a problem, my code is exactly like yours, but  the Author link doesn’t do anything when I click it and it doesn’t bring me to an archive page where I can see the ‘Author Archives’ : and the name of the author here.

    This is the code for the author: 

    elseif (is_author()) {
    echo ‘Author Archives: ‘. get_the_author();

    <a href="”>

  3. Excellent tuto, however there is a question about categories which dont show
    the get_the_category() doesn’t return any categorie inspite of the fact that there are categories already created, it seems they are not added
    if you do a test 
          echo ” there is no categories;
    it prints there is no categories

  4. Brad, your way of teaching is clear and effective, I think you are really great at it. With the same clearness could you explain to me why some WP built-in functions requires the “echo” command to print on the screen the return value (like get_the_date()) while some other doesn’t (like single_cat_title())? Thank you in advance…

  5. Please answer my comment. I have a problem, my code is exactly like yours, but  the Author link doesn’t do anything when I click it and it doesn’t bring me to an archive page where I can see the ‘Author Archives’  and the name of the author here. It’s only work on the category page.

  6. Brad in this video you mention a previous video you mention how to link to archive pages. for the author and category.  Where Can I find this video?

  7. Thank You a lot for the tutorial. However, I have a little problem. When I click on the author hyperlink, it doesn’t show the archive, but when I click first on the category archive and then on the author archive, it does. I believe it’s because the author is below the category in the elseif skeleton. Would You have any ideas how to solve it? Thanks

  8. +LearnWebCode  Hey, great tutorials so far. I find them immense! I am no coder, I am learning, but I do have a question – is there a reason that you use the elseif statements instead of a switch statement??

  9. Downright spectacular series of WordPress tuts! Thorough, clear, concise and very, very, very helpful (that’s three layers of helpful, everyone)!

    I would just like to like to point out that, under this particular tutorial, some might come across difficulties caused by the mod_rewrite module not being set in the .htaccess file that is required to go in the theme root folder for “Pretty-Permalinks” to fully work.

    If you are stumbling upon Not Found messages trying to view the archive page you might want to read this up: http://codex.wordpress.org/Permalinks/

    Thank you so much for your excellent work!

  10. Anybody know why we’re using a switch statement here instead of the long list of elseifs? Also, why don’t we just put the h2 tag above the if(have_posts()); instead of breaking the if statement in the middle?

  11. Pretty good tutorial so far.
    Does WP automatically looking for “archive.php”? Or how does he know, that he have to execute that file, if you did not link to it.?

  12. Had to write the following to avoid syntax error … elseif( ‘ ‘ ) { echo ‘Archives:’ ; }

  13. Hi, thanks a lot for you best tutorial but i know that have you any woocommerce theme devloop tutorial ..

  14. Brad, if i click on my category, the site displays “No content found”. How can i resolve that problem? Or does anybody here know how?

  15. Everything seems to be working for more except I cannot access any of the date archives, is there some option that I need to select?

  16. Interesting to see how Lesson 1 had 600k views and as we dig deeper it gradually comes down to 40k. We are the survivors, everyone gave up… 😀

  17. Hey, Brad, I was just watching your tutorial and I had a question, is there a way to create archives for different blog pages, not POST themselves. Like if I have a blog for tacos and a blog page for cats, would it be possible to create an archive for both of those topics and keep them separate? Any help or direction is appreciated!

  18. I just finished creating the archive section for my new personal blog theme, and I saw that you did a video on archives, still gonna watch it.

  19. I need to develop a sections that get the photos uploaded on the current date, like a newspaper has pages to display on front-page for their viewers. What is the concept best matches that it shows photos of the pages if the date is similar.

Comments are closed.