WordPress Archive Tutorial (archive.php)

[ad_1]
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 $4.95 a month ($60 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:


Posted

in

by

Comments

38 responses to “WordPress Archive Tutorial (archive.php)”

  1. Marcos Di Paolo Avatar

    Hi!!
    10:20
    and post formats??????????
    is_format() does not exist and neither has_format() nor get_the_post_format() would work for this purpose!!!

  2. Romy Kim Avatar

    I set out to learn to make website several months ago and have been going back and forth between hand coding and WordPress. WordPress has been much easier but it also has nasty layout issues. (I felt so restricted) Some CSS editing worked, but eventually, I am back to learn from you.(I've been thinking about re-watching this series, but it felt very stressful… I just wish I came back earlier) I am learning at a whole different perspective and level now and seeing some real hopes to get the best of hand coding and WordPress. THANK YOU !!!!

  3. Nano Byte Avatar

    Most simple . elegant tutorial for WP ever seen on UTUBE…………..

  4. TheWaqaspuri Avatar

    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.

  5. r4xe Avatar

    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.

  6. Romy Kim Avatar

    Is "archive.php" a filename assigned by WordPress to start with ?

  7. Axel Pantheon Avatar

    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!

  8. Igor Aherne Avatar

    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… 😀

  9. Kevin Houk Avatar

    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?

  10. wawa wawar Avatar

    very very well explain

  11. Floris de Boer Avatar

    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?

  12. Rafiul Islam Avatar

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

  13. bihlanna Avatar

    Had to write the following to avoid syntax error … elseif( ' ' ) { echo 'Archives:' ; }

  14. Vitezslav Omelka Avatar

    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.?

  15. Konto Prywatne Avatar

    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?

  16. José Brites Avatar

    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!

  17. Husain Ahmmed Avatar

    Every part is awesome learn lot's of thing easily.

  18. Gareth Dackevych-Thomas Avatar

    +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??

  19. Adam Klepáč Avatar

    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

  20. Loki King Avatar

    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?

  21. Hao Luo Avatar

    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.

  22. Andrea Lmb Avatar

    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…

  23. margoumix Avatar

    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 
    if(!$categories)
      {
          echo '' there is no categories;
      }
    it prints there is no categories

  24. Duban Soft Avatar

    Can't buy your courses, but I really thank you so much… Greeting from Colombia!

  25. Chris K Avatar

    Brad, the coupon code for the CSS course is gone! Can you put it back up?

  26. Minhajul Islam Rahid Avatar

    The Best Tutorial Ever I Have Seen In My Life 

  27.  Avatar
    Anonymous

    Thanks, It is very Helpful.

  28. MRbombonel Avatar

    +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()) {
    the_post();
    echo 'Author Archives: '. get_the_author();
    rewind_posts();
    .
    .
    .
    .

    <a href="<?php get_author_posts_url(get_the_author_meta('ID')); ?>"> <?php the_author();?> </a>

  29. DrunkenShinobi Avatar

    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"…

  30. vijay singh Avatar

    Your teaching method is awesome i am subscribed with your channel now…..thanks.

  31. rubel hossain Avatar

    Awesome, I find clear concept in yiur tutorial.when i visit youtube look at your channel friquently to finding new tutorials.I want to get more awesome tutorials…waiting……..

  32. Paul Douglas Avatar

    Brad, I want to let your viewers know that hands-down, you are the most thorough and detailed teachers that I have ever seen online. I have viewed thousands of different videos with many, many "teachers".  I have learned and retained more from each of your videos than any other service including paid services like Linda.com and Treehouse. To use a metaphor of yours, the content is 'easy to digest'. Not only that but your vocabulary and the way you use the English language is easy on the ears. I will be recommending you to all of my customers that want to learn more about their WordPress installation. Thank you

  33. Session Street Avatar

    dunno what i did wrong. all links are is showing a Not Found Page. Please help

  34. sayed akbarali Avatar

    Thank you for these wonderful tuts

  35. Logan Pennington Avatar

    I really appreciate you making these videos. Please keep being awesome!

Leave a Reply

Your email address will not be published. Required fields are marked *