WP Theme Lesson #6c: Get Archives and Links
Today’s lesson is fairly easy. You’ll learn how to call for an archive link listing and the blogroll links. Tomorrow’s lesson is the calendar and search form.
Before we start, I want to explain why I’ve been breaking down my lessons into smaller lessons. Everything that you’re learning took self-taught people MONTHS to digest! It’s important that you understand everything I’m showing you the first time around so you won’t have to go back and re-check.
Step 1 - Add archive links.
Type the following codes in the Sidebar area, under the Categories listing:
<li><h2><?php _e(’Archives’); ?></h2>
<ul>
<?php wp_get_archives(’type=monthly’); ?>
</ul>
</li>
Give it some tab spacings for organization. Let’s see if your codes match mine:

Save your file, refresh the browser, here’s the result:

What happened?
You used the wp_get_arhives() PHP function with the type attribute and monthly value to call for the archive links by month.
- <li> - open list item
- <h2> - open sub-heading
- <?php _e(’Archives’); ?> - text of the sub-heading
- </h2> - close sub-heading
- <ul> - open unordered list under the sub-heading, within the list item
- <?php wp_get_archives(’type=monthly’); ?> - call for archive links by month, nest each link within <li> and </li> tags. If you check your source codes (View > Page Source). You’ll see that wp_get_archives() generated list item (LI) tags for each link, just like the wp_list_cats() function.
- </ul> - close the unordered list sitting under the sub-heading
- </li> - close list item
Step 2: Add blogroll links
Type the following codes under the Archives link listing:
<?php get_links_list(); ?>

Save, refresh, and here’s the result:

By default, my blogroll is no different from yours. Here’s how it looks in the source codes:

The organization is not all there because the get_links_list() function generates the codes for you, just like the wp_list_pages() function you learned about, from yesterday’s lesson. However, it stuck with rule number one, which is close everything in the order that you open them. I circled the list item and unordered list tags for you to see.
That’s the end of today’s lesson. Come back tomorrow for the calendar and search form.
Follow this WordPress Theme Tutorial Series from the beginning.


Hey, I just love your lessons, there are very helpful and very easy to understand. But I have one question. I’m using Wordpress and I have found a nice theme that I have modified. The problem is that I want to change the column for my sidebar, it’s a two column now and I want to change it to a one column sidebar and leave the extra space for the index file. How do I do that?
Please post this at http://www.wpdesigner.com/forums and link me to the theme you’re talking about so I can help you. Thanks.
[…] ID, Link Title #5e Posts Nav Link #6 Sidebar (and Categories) #6b Page-Link Listing (wp_list_pages) #6cGet Archives and Links #6d Search Form and Calendar #6e Widgetizing Sidebar #7 […]
Love this learning opportunity! I am having trouble with php_e. It returns this: Fatal error: Call to undefined function php_e()
It happened in an earlier lesson and I simply changed it to display without the php_e but when it happened today I started wondering why this might happen. Any clue?
Thanks
Oh - I just found my problem! I was not leaving a space between php and _e. Sorry - silly me.
SP, where can we get a documentation of a list of attributes that we can use?
like
SP, where can we get a documentation of a list of attributes that we can use?
like php wp_get_archives(’type=monthly etc..
wordpress.org DOCS
wow that was simple, especially the blogroll links lol, i just have to remember that one code.
very good!!
I just saw on the following blog a drop down list for both
archives and categories. I would love to learn how to do THAT.
see it at http://bothack.wordpress.com/
nada
Small Potato;
I have a query here, why wouldn’t the Blogroll be the default size like pages?
Is it always like this that i don’t have to resize the word ‘Blogroll’?
Small Potato,
Thanks so much for your great tutorial! Before, I didn’t get along with PHP at all and had merely no idea about the possibilities of CSS. Thanks to your tutorial, I’m now able to customize my own blog with my own design. Thanks again!
My question: Is it possible to open blogroll links in a new browser window (target=_blank)?
With only one command involved (php get_links_list), I can’t imagine how to do that. Thanks for any help in advance!
Many greetings from Switzerland
Bubble
You can control that through your links management page.
I am wondering how one would go about using wp_list_bookmarks in place of get_links_list or get_links.
Any thoughts on how to modify this?
if you want your theme to stay up to date, simply replace get_links_list with wp_list_bookmarks
Hy!
Can you tell something more about css editing blogroll
…
Step 2: Add blogroll links
Type the following codes under the Archives link listing:
…
How can I edit it so it wouldn’t be Blogroll which is deafult)
Cheers
Go in links management, change the Blogroll category to something else.
Is there a way to control the title of the blogroll like we could with the pages list? This is really essential for my design.
No, but I’m not sure.
For reference I used wp_list_bookmarks(’title_li=&categorize=0′);
SP,
Wow, what more can I say man? I am “one of those” people who have made several attempts to learn this whole WP and PHP thing with next to no success in the past. As you mentioned in the intro to this lesson, I try to digest too much too fast and seem to get lost (not to mention it takes true talent such as yours to really teach something like this). I am plugging away over the past 3 days in bits and so far, I’m with ya man. Experienced a few bugs trying to load the whole Xampp thing initially, and been working diligently to solve my own coding errors (the truest way to learn, I feel); so far soo good. Thanx a million bro. Hope your time devoted to this gives you your edge in your goal to a million!!
Thanks Erik, your comment is much appreciated. Although I haven’t posted anything about the million dollar challenge for a while, I’m working on it behind the scenes
how can I edit the ‘blogroll’ name to be something else? Such as ‘Links’ or ‘My Favorite Websites’?
wp_list_bookmarks(’title_li=TITLE HERE′);
where do i put that exactly? and do i have to add the
info? i tried a couple of different ways with no luck
Put that piece of code wherever you want the list to appear in your template
Sorry this piece of code!
<?php wp_list_bookmarks(’title_li=TITLE HERE′); ?>
yea it gives me an error for some reason. I tried taking out the and putting that one in and I get the error. I tried putting them both in, and I still get an error. LOL - I’m so clueless! Here’s the error I get after I save & refresh: Parse error: syntax error, unexpected ‘=’ in C:\xampplite\htdocs\wordpress\… on line 115. I know it’s talking about the ‘=’ symbol in there, but if I take that out, I would get an error either way. Any clue what I’m doin’ wrong… cuz I have NO idea! (btw, thanks for all your help)
The ul tags aren’t needed, validator make an error with those tags. Doens’t change anything to the outcome.
the ul tags are needed to code valid xhtml lists
Greetings linnette,
Hope you solved the issue.
Else,
Do not copy and paste the codes.
Type it out.
Reason is because of the ‘ mark in between the brackets.
Cheers
In terms of changing the title “BlogRoll”, I was able to do so through the Admin Panel of Wordpress. It is under the ‘Blogroll’ heading, and ‘Categories’ subheading. You can either add a new category, or Edit the one called ‘BlogRoll’. I changed it to read “Links”, and it automatically updated.
Absolutely wonderful tutorial. Even though I know most of the code and what it does, I’m not frustrated and feeling like you’re baby talking to me. I am also still learning things through your tutorial. Which is the reason I’m using it. I’m a WordPress beginner.
My Comment: Do you have any idea why WordPress would make these codes behave in such different ways? For example: Categories and Archives don’t have the title already in the function, but Blogroll and Pages do. Why is that? They should have picked one way or the other to display them.
Thanks again for this tutorial, I am definitely going to suggest this to anyone who wants to customize WordPress.
I don’t know VIRA.
Ive been trying this before but always had to rush out so this is a nice easy step by step way for me to learn in a bit of free time (granted ill come back to keep checking what im doings correct) lol
Hi man!, well firstly thank you so much for dedicating this time to beginners like me, and now the question:
I’m having problems in this part of the tut.
I had to take out the
and replace it like this: Archives
otherwise it gives me an error.
could you help me please?
Thanks man!
Hey men,
When i put the following code in my index.php:
Then i save it and refresh my browser but all i got was a white page, could you explain why and how i fix it? If possible, could you email my back. I want to learn this very much.
Greets from Holland!
Thanks again. I won’t get tired saying thank you…(kaawaan ka nang diyos) <—–GOD BLESS