Today, your’s truly brings to you a guide to showing links in your link manager ordered by the most recently updated weblogs. This is useful when you have a lot of blogs in your link roll, and you want to show the links in the order of “freshness” of the blogs, that is, with the most recently updated blog appearing first in the list.
Ok, I am bored. No one has anything interesting to say about WordPress today. Today being a Saturday (early Sunday already, actually), and all that. So I thought I will write a long tutorial for you.
You can see this in action at Molly’s blog, where the links in her Blogroll are in the order updated — “freshest to mustiest“, as she so eloquently puts it. Matt’s Portal page is also a good example of this.
1) Get a plugin and update it.
2) chmod a file.
3) Set the right options.
4) Add the right template tag.
Now, for a detailed blow-by-blow account :
a) Save the Update Linkroll plugin which was Carthik’s first ever plugin .
b) Rename the file as updatelinkroll.php
c) Upload it to your wp-content/plugins folder.
d) Activate the plugin from the plugins page visible at the administration interface after you log in.
a) CHMOD the links-update-cache.xml file in the wp-content folder to 766 (so that it is writable by wordpress)
b) Notice the existence of a file called link-update-cache.xml (link, not links) in wp-content and pat yourself on your back for not getting confused between this imposter and the real file that does all the work, which you CHMOD’ed. You don’t need the link-update-cache.xml file at all, so go ahead and delete it, if you like. Helps avoid confusion, you know.
a) Tweak the options in wp-admin/options.php?option_group_id=8 (The link manager options)
The following options are the ones related to displaying updated links:
- weblogs_xml_url – You won’t need to change this. This specifies the URL of the xml file with the list of recently changed weblogs.
- weblogs_cacheminutes – Specify the number of minutes WP waits before it updates the cached list of recently updated blogs it got from weblogs.com (something like 30 or 60 should be fine, really)
- links_updated_date_format – The date format for the updated tooltip, leave it the way it is, if you are not too particular about minutae.
- links_recently_updated_prepend – The text to prepend to a recently updated link
- links_recently_updated_append – The text to append to a recently updated link
- links_recently_updated_time - The time in minutes to consider a link recently updated
Add a suitable template tag to your index.php where you want the list of links to appear. The following template tag works, so it’s a good place to start, when in doubt:
<?php get_links('-1','<li>','</li>',' ','true','_updated','false','false','-1','1','true'); ?>
More details about that template tag are available at the get_links wiki page.
Or, you can use wp_get_links()
to display the links. You can order the list by “recently updated” by clicking the “Links” tab in the admin interface, and then link-categories (wp-admin/link-categories.php). There, for each category, you can decide the order of display of links. The whole idea is that you use the wp_get_links to display the list of links, and you use the “Links” menu in the admin interface to adjust everything about how the links are displayed.
The link manager in WordPress is largely the effort of Mike. He was extremely helpful in understanding how the links manager works. Thanks, Mike