WordPress Archive Tutorial (archive.php)
ฝัง
- เผยแพร่เมื่อ 5 ก.ย. 2024
- Join my 2024 Complete WordPress Course here learnwebcode.t...
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).
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):
learnwebcode.co...
Sign up for my newsletter to receive periodic webDev tips, tricks, resources and coupons. Join the list at learnwebcode.com/
Follow me on Twitter for updates and cat pics:
/ learnwebcode
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
Paul Douglas Thank you so much - you win the "nicest comment of the decade" award! Really appreciate the kind words. I'm glad the videos are helpful and I'll try to keep the WordPress content flowing :)
I couldn't agree more with the above statement. Can't wait for MORE topics of education from you. Oh and btw, I bought your 7-hour course. Can't wait to dive into that. Thanks again, Brad.
I have to echo Paul's sentiments. You are clear and concise and you explain at a level that novices can understand. Great Job.
I would like this infinite times if possible, I have pretty much learned most of my knowledge of wordpress/js/jquery from Brad's channel. Pretty much the perfect teacher, with easy to understand explanations.
agreed. he's a fantastic teacher ans simplifies everything so well.
It's 2019, and these set of old tutorials are really relevant, and that's regardless of your current WordPress version. And Yes! - Some internal functions have been duplicated, but at least we can see them being built here, and through that building process: we can now see how the footings have been laid down in the first place.
Archives Rule.
It's all worth it, .. cos' your worth it.
Thank you Brad.
Ditto, 2024
Well done! One critique would be it is a better practice to use a "switch" statement with that many conditions.
This has been a great series to watch! Thanks for all of the hard work!
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... :D
Ahah i was telling myself the same thing :p but I need time to $digest ahahah
interesting tells me maybe some people just want to build one website and customize a little not learn code and make it our life. Each video does not stand alone they are a series most people dont have time for. How successful do you think Starbucks would be if they only sold to yuppies?
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.
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 !!!!
Can't buy your courses, but I really thank you so much... Greeting from Colombia!
Duban Soft You're welcome! Thanks for watching and I'm glad the videos are helpful!
so far ,so good i completed all the previous lession and today looking forward to this video .You are awesome brad
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........
Every part is awesome learn lot's of thing easily.
Your teaching method is awesome i am subscribed with your channel now.....thanks.
Love you man! Always coming back to this videos :)
I really appreciate you making these videos. Please keep being awesome!
Thanks, Logan!
Thank you very much Brad for posting this video
Hi Bard,
I am impressed how you are teaching in these videos, I have one question.
on the Archive page -> inside the tag we can use the WordPress builtin function, which returns everything automatically instead of writing whole conditional logic
what do you say?
Thanks
Sorry Brad, My Bad, i have figured out why you didn't showed that function in your video. because it was introduced in WordPress v 4,10 and you made this video 3 years ago.
Great Job (y)
Thanks for the information. How did you learn about this? Is there a video or place where I can learn about WP v 4.10 apart from the documentations?
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
this is the best toturial
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...
Andrea Jimbo Great question. I think that is a result of the developers of WordPress trying to anticipate what we typically use a particular function for. For example, sometimes we just want to store a bit of data in a variable, or check to see what it's value is for an IF statement, etc... in those cases the function doesn't need to actually print or "echo" anything, it just needs to return a value. In other situations, the developers of WP realize that if we are querying for a blog posts title, it's probably a safe bet that we will also want to "echo" or print it out onto the page. In those cases, the WP devs are kind enough to bake the "echo" directly into the function to make our lives easier :)
Thank you for the prompt reply, clear as I expected. I'm not a coder, I'm trying to learn to develop a WP theme through your tutorials. So I might ask you some other question in the future, hoping not to bother you too much :)
LearnWebCode In my humble opinion, it just confuses people to "bake in" echo to certain functions and not others. It is a lot of memorization and most people work with many other languages if they are a coder.
+Anthony Rosamilia There is always the WordPress Codex you can use as a reference how to use the functions. You can find them at codex.wordpress.org/ a very helpfull page.
Or go directly to the WordPress Code Reference: developer.wordpress.org/reference/
Click on functions and you see only functions.
Thank you for these wonderful tuts
I'm glad you find the videos useful!
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?
Very Good lesson :) greets from NZ
Hi, thanks a lot for you best tutorial but i know that have you any woocommerce theme devloop tutorial ..
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??
+Gareth Dackevych-Thomas I think he wants to keep it as simple as he can. I think a switch statement should be possible as well.
Thank you very much !
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.
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
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.
Can you paste the code here.
I faced the exact same issue with the author archives.The author link does not show up anything.Were you able to fix it?I just started watching these videos and I can see that you posted this reply a long time back,did you get through with the author archives issue.
very very well explain
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?
What is an archive? Type of page or post? What kind of entity? Is there something actually being archived, and what is that?
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?
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?
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.?
+Vita O I guess he also mentioned that in the start of the video, but WordPress has a build-in function to go to the archive.php, when present, if a category, tag, name or date list is needed.
You can check other theme folders like twentyfifteen for list of available pages.
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"...
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!
Hi Axel, I'm not 100% sure I understand the setup you're describing - but would category archives help? One page that's a archive of the "Tacos" category and another page that's an archive of the "Cats" category?
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!!!
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();
.
.
.
.
Brad, the coupon code for the CSS course is gone! Can you put it back up?
Is "archive.php" a filename assigned by Wordpress to start with ?
dunno what i did wrong. all links are is showing a Not Found Page. Please help
Darling Bryan You can download the files I created in the video (link in description) to compare your code. If you don't have any typos, I would begin by heading into the WordPress Admin dashboard, going into settings -> Permalinks and making a change to the permalink structure and save, and then set it back to whatever setting you prefer and save again.
LearnWebCode Thanks. I figured out the problem. It was on my Apache config. Thanks for the reply. Awesome tutorial btw.
great job (Y)
get_the_date(); does not showing any date
🗽
Fantastic tutorial!
I removed all the content from the archive pages BUT I can't figure out how to remove the white blank space and the grey line that used to separate the posts in the category/archive pages. Could you please tell me if there is a code I need to add to remove these blank areas in the archive pages? I leave a link below to one of the archive pages
bestellipticalmachinehut.com/proform/
Thanks a lot in advance.
echo "nice video";