Late on Friday they finally released WordPress 2.9. Have you upgraded yet? Most people should be able to do it with the click on a button at this point, but if not you can download it here.
If you haven’t upgraded yet, here are some of the new features you’ll have when you do:
- Built-in image editor that lets you crop, edit, rotate and scale your images.
- Global “trashcan”, which means that posts or comments you delete won’t immediately go away into the ether. So you can restore anything you deleted by accident.
- Easier video embedding.
- Easily assign thumbnails for all your posts, which are great for magazine style blogs and food blogs. (You can see an example of how I used the new Post Thumbnail feature on Cooking with Michele. The thumbnails are being utilized for the “related posts” under every post, as well as on the archives, categories and search pages.) Here’s a great tutorial if you want to know how to set up Post Thumbnails on your site.
- Automatic database optimization, which is an important thing to do to keep your WP install running well, but most people who aren’t designers/developers wouldn’t have any clue how to do themselves. Now all you have to do is add this your wp-config file:
define('WP_ALLOW_REPAIR', true);
That’s just some of the big stuff, there are tons of small improvements and bug fixes. You can read a longer list over on the Dev Blog. Or you can watch this video for the highlights:
Permalink | Leave a Comment
Copyright © Swank Web Style 2005-2009.
This feed is for personal, non-commercial use only. The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:
3218012a1d52458cc65f7ca3d7
There is a worm that has been making it’s way around since yesterday that is attacking WordPress blogs with older versions. If you haven’t upgraded to the current version, please do so right now. Otherwise there is a very high chance your blog will be compromised and it’s much harder to clean up a hacked blog than to upgrade it and keep it secure in the first place.
I’ve noticed some confusion among users at other sites, so I want to make this clear. If you have the current version of WP, which is 2.8.4, you are safe, your blog is immune from this worm. If you have an older version, especially a much older version, you need to upgrade ASAP. Also, this only applies to self-hosted WP blogs. Blogs on wordpress.com aren’t affected because they are always current.
Matt goes into specifics about this worm and the importance of upgrading over on the dev blog and I encourage you to go read it.
If you have version 2.7 or above you should be able to upgrade automatically. It’s extremely simple. In your WP admin, just click on Tools>Upgrade and click on the button that says “Upgrade Automatically”. It takes about 10 seconds and you’re done. I’ve upgraded hundreds of blogs this way and have never had any problems. (Note: this doesn’t mean you shouldn’t make a backup beforehand, you should be making regular backups of your blog anyway!)
The only thing that might be an issue as far as the automatic upgrades is if you are using either of the default WP themes. Those WILL get overwritten. The best way to guard this from happening is to rename your theme. You can follow the simple instructions here. As long as you aren’t using the default theme, though, your theme will NEVER be touched in an automatic upgrade.
If you have an older version of WP that doesn’t have automatic upgrades or your host doesn’t support that feature or you’d just feel safer doing it yourself, it’s still very easy to upgrade WordPress. I wrote a tutorial about upgrading WP a few years ago and the instructions still apply today.
Whether you spend the 10 seconds upgrading your blog automatically or the 5 minutes to upgrade manually, it’s extremely important that you always upgrade when a new version comes out. The new version is always the best, most secure version to have. And if the developers at WP find a new problem they will keep putting out new versions until that problem has been fixed (this is especially true since the automatic upgrades have been introduced). If you don’t upgrade you are opening yourself up to being taken advantage of by people that want to exploit these problems that the developers work so hard to fix.
So what do you do if you’ve already been hacked? Here are several helpful posts with instructions to fix it:
I also wrote several posts about how to clean up a hacked WP blog and prevent it from happening again:
- Fixed a hacked site and prevent it from happening again – Part 1
- Web 101: Fixed a hacked site and prevent it from happening again – Part 2
And if your blog is just totally, irrevocably screwed up (which has not been my experience with this particular hack, I’ve fixed 3 blogs already just using the first link above), here’s a good tutorial for getting a copy of your content and starting fresh:
And just a reminder to Swank Web Hosting customers: Upgrades are free! I encourage you to use the automatic upgrade feature, but if you have a really old version of WP or you aren’t sure about upgrading yourself, please contact us and we’ll get you set up with the current version of WP.
Related posts:
- WordPress 2.7.1 Released
- WordPress 2.6.1
- WordPress 2.8.2 – Security Update
- WordPress 2.5 has been released!
- WordPress 2.5.1
Permalink | Leave a Comment
Copyright © Swank Web Style 2005-2009.
This feed is for personal, non-commercial use only. The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:
3218012a1d52458cc65f7ca3d7
Adding related posts to your blog is a great way to help your readers find other posts on your site that interest them. And if you have ads, increasing the number of pageviews on your blog can turn out to be quite lucrative. I recently had a request from a client to use a certain widget that she had seen on many other blogs that adds a list of recent posts along with a thumbnail image from that post. But after looking at the widget and researching the many other plugins that are available to add this functionality, I decided I wanted to find a way to code it directly into the template.
One reason for this is that the more plugins installed on a blog, the more that can slow down the loading time of that blog. If you can hard-code a function into the template, it’s almost always preferable to using a plugin. Plus many of the plugins or widgets I looked at gave very little control over things like styling or where the list appears in the template or even how they even figured out what was “related”. What if you want them to be related by tag instead of category or vice versa? What if you just want other posts by the same author?
After doing some more googling and modifying some of the code I found I figured out how to do everything I wanted to and more. My client was extremely pleased with the results and was amazed that I’d even been able to implement it without using a plugin or the widget she had originally wanted:
“It IS cool! A zillion people are going to see it now and want it on their WP blogs! Thanks!”
Which leads us to this post. I thought I would share my findings so that you can implement the same feature on your own WordPress blog. Below I will show you how to add related posts by category, tag or author. I will preface this by saying you should probably have some very basic knowledge about how to edit a template in WordPress, but for the most part, you can copy the code directly and paste it into your template. That’s it. For people with more advanced knowledge I’ll point out things that you can edit further and customize to your liking.
Where to add the code:
To start, you should figure out where you want your related posts to show up. Generally, you are going to want to include this on your single post page, which is the page that has the full post including comments. In your WP admin, click on Appearance>Editor and look for the template called Single Post or single.php. You may also want it to show up on your main page (index.php) and your archives (archive.php). If you do want this to show up on all three templates, generally you can just copy and paste the same code in the same spot on all of them, but some themes may have the archives or index page formatted differently. When in doubt just put it on the single post template and that’s probably enough.
There will be two separate pieces of code and two different places you need to find in your template to insert them. The first is the beginning of the WP loop and the second is the spot that you want the related posts to show up.
The beginning of your loop is going to look like either of these:
- <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
- or
- <?php if (have_posts()) : ?>
The first code snippet should be inserted directly above this line. It’s very important that it’s above because you want it to be outside of the loop. It can create some very weird behavior otherwise, which I found out in the trial and error of testing all of this.
The other code snippet will be inserted inside the loop in the place where you want the related posts to appear on your page. If you’re not sure where it should go generally you are going to want it at the bottom of the post either after the post ends or after the comment link (assuming that’s at the bottom of your post). Look in your template for something that looks like this and insert the code somewhere underneath. You can always move it around until it appears in the place you want it to.
- <?php the_content(); ?>
- <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
Adding Thumbnails:
If you want to display thumbnails, you will have to go one step further and add a thumbnail image custom field to your posts. If you want, you can just start doing this on your most recent post, but you may want to go back through previous posts and add thumbnails to them as well (at least the last 5 posts or however many you want to display). Until you have a bunch of posts with thumbnails assigned, it won’t have too much to choose from when displaying the related post list.

Adding a custom field is simple. If you haven’t already, upload your photo in WordPress. If you’ve already uploaded the image you want to use, open the uploader and choose the image you want from the gallery. The WP uploader will have created different sizes for you. By Alignment, choose Left and by Size, choose Thumbnail and click the ‘Insert into Post’ button. Copy the entire code snippet and scroll down the post page to the box that says Custom Fields. Under “Add new custom field” click on the “Enter New” link. Under “Name” type: thumbnail. Paste your image code into the large box under “Value”. Click on the button that says “Add Custom Field”. That’s it. Finish and publish your post like normal.
See it in Action:
Below is the code you need to implement these functions on your blog. Copy it into your template and you’ll have a simple unordered list without thumbnails. Read the further customization section for what you need to change to make it display thumbnails and other customizations like changing the number of posts or what order they appear in.
But before you see the code (which I realize may just look like a bunch of gibberish to some people), here are some examples of it in action:
Related by Category, with thumbnails:
Related by Tag: Look at the bottom of this very post (or any of the posts on this blog) to see the related post list using this function.
Skip Directly to the section you want:
Related Posts by Category
Via DarrenHoyt.com
This code searches other posts in the same category and returns the title of 5 random posts in list form.
Insert this above your loop:
- <?php
- //Gets category info
- global $wp_query;
- $cats = get_the_category();
- $tempQuery = $wp_query;
- $currentId = $post->ID;
-
- //related category posts
- $catlist = "";
- forEach( $cats as $c ) {
- if( $catlist != "" ) { $catlist .= ","; }
- $catlist .= $c->cat_ID;
- }
- $newQuery = "posts_per_page=6&orderby=
rand&cat=" . $catlist;
- query_posts( $newQuery );
- $categoryPosts = "";
- $count = 0;
- if (have_posts()) {
- while (have_posts()) {
- the_post();
- if( $count<5 && $currentId!=$post->ID) {
- $count++;
- $categoryPosts .= '<li><a href="' . get_permalink() . '">' . the_title( "", "", false ) . '</a></li>';
- }
- }
- }
- $wp_query = $tempQuery;
- ?>
Insert this in the spot that you want the list to show up:
- <h3>Related Posts</h3>
- <ul>
- <?php echo $categoryPosts; ?>
- </ul>
Further Customization
Change the number of posts that show up:
1. On Line 14 of the first snippet, change the number ‘6′ to the number of posts you want plus one. So if you want 10 posts, put in 11.
2. On Line 21 change the number ‘5′ to the number of posts you want to show.
Change the order of posts that show up:
1. On Line 14 change orderby=rand to any of the following:
- orderby=author
- orderby=date
- orderby=title
- orderby=modified
- orderby=ID
Display thumbnails, with post title underneath:
1. Change Line 14 to:
- $newQuery = "posts_per_page=6&meta_key
=thumbnail&orderby=rand&ca t=" . $catlist;
This tells it to only search for posts with a thumbnails. If all your posts have thumbnails, then you can skip this step.
2. Change Line 23 to:
- $categoryPosts .= '<li><a href="' . get_permalink() . '">' . get_post_meta( $post->ID, "thumbnail", $single = true ) . '</a><br />
- <a href="' . get_permalink() . '">' . the_title( "", "", false ) . '</a></li>';
This is the formatting. Both the thumbnail and the post title below it link to the post’s permalink.
3. You may also want to style your thumbnails (add a border, spacing between them, etc.). The alignleft class should already be in your stylesheet if you have any kind of standard WP theme, but if you don’t see it listed, add this to the end of style.css for some basic styling:
- img.alignleft { float: left; }
- img.size-thumbnail { padding: 10px; }
Related Posts by Tag
I combined code from DarrenHoyt.com and Techie Blues for this function.
This code searches other posts with the same tags and returns the title of 5 random posts in list form.
Insert this above your loop:
- <?php
- global $wp_query;
- $tags = wp_get_post_tags($post->ID
);
- $tempQuery = $wp_query;
-
- if ($tags) {
- $tag_ids = array();
- foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
-
- $newQuery=array(
- 'tag__in' => $tag_ids,
- 'post__not_in' => array($post->ID),
- 'showposts'=>5, // Number of related posts that will be shown.
- 'orderby'=>rand,
- 'caller_get_posts'=>1
- );
- query_posts( $newQuery );
- $tagPosts = "";
- if (have_posts()) {
- while (have_posts()) {
- the_post();
- $tagPosts .= '<li><a href="' . get_permalink() . '">' . the_title( "", "", false ) . '</a></li>';
- }
- }
- }
- $wp_query = $tempQuery;
- ?>
Insert this in the spot that you want the list to show up:
- <h3>Related Posts</h3>
- <ul>
- <?php echo $tagPosts; ?>
- </ul>
Further Customization
Change the number of posts that show up:
1. On Line 13 from the first snippet, change the number ‘5′ to the number of posts you want to show.
Change the order of posts that show up:
1. On Line 14 change ‘orderby’=>rand, to any of the following:
- ‘orderby’=>author,
- ‘orderby’=>date,
- ‘orderby’=>title,
- ‘orderby’=>modified,
- ‘orderby’=>ID,
Display thumbnails, with post title underneath:
1. Under Line 13 add:
- 'meta_key'=>thumbnail,
This tells it to only search for posts with a thumbnails. If all your posts have thumbnails, then you can skip this step.
2. Change Line 22 to:
- $tagPosts .= '<li><a href="' . get_permalink() . '">' . get_post_meta( $post->ID, "thumbnail", $single = true ) . '</a><br />
- <a href="' . get_permalink() . '">' . the_title( "", "", false ) . '</a></li>';
This is the formatting. Both the thumbnail and the post title below it link to the post’s permalink.
3. You may also want to style your thumbnails (add a border, spacing between them, etc.). The alignleft class should already be in your stylesheet if you have any kind of standard WP theme, but if you don’t see it listed, add this to the end of style.css for some basic styling:
- img.alignleft { float: left; }
- img.size-thumbnail { padding: 10px; }
Related Posts by Author
Via DarrenHoyt.com
This code searches other posts by the same author and returns the title of 5 random posts in list form.
Insert this above your loop:
- <?php
- //Gets author info
- global $wp_query;
- $postAuthor = $wp_query->post->post_auth
or;
- $tempQuery = $wp_query;
- $currentId = $post->ID;
-
- //related author posts
- $newQuery = "posts_per_page=6&orderby=
rand&author=" . $authorPosts;
- query_posts( $newQuery );
- $authorPosts = "";
- $count = 0;
- if (have_posts()) {
- while (have_posts()) {
- $count++;
- the_post();
- if( $count<5 && $currentId!=$post->ID) {
- $count++;
- $authorPosts .= '<li><a href="' . get_permalink() . '">' . the_title( "", "", false ) . '</a></li>';
- }
- }
- }
- $wp_query = $tempQuery;
- ?>
Insert this in the spot that you want the list to show up:
- <h3>More Posts by this Author</h3>
- <ul>
- <?php echo $authorPosts; ?>
- </ul>
Further Customization
Change the number of posts that show up:
1. On Line 9 of the first snippet, change the number ‘6′ to the number of posts you want plus one. So if you want 10 posts, put in 11.
2. On Line 17 change the number ‘5′ to the number of posts you want to show.
Change the order of posts that show up:
1. On Line 9 change to orderby=rand to any of the following:
- orderby=date
- orderby=title
- orderby=modified
- orderby=ID
Display thumbnails, with post title underneath:
1. Change Line 9 to:
- $newQuery = "posts_per_page=5&meta_key
=thumbnail&orderby=rand&au thor=" . $authorPosts;
This tells it to only search for posts with a thumbnails. If all your posts have thumbnails, then you can skip this step.
2. Change Line 19 to:
- $authorPosts .= '<li><a href="' . get_permalink() . '">' . get_post_meta( $post->ID, "thumbnail", $single = true ) . '</a><br />
- <a href="' . get_permalink() . '">' . the_title( "", "", false ) . '</a></li>';
This is the formatting. Both the thumbnail and the post title below it link to the post’s permalink.
3. You may also want to style your thumbnails (add a border, spacing between them, etc.). The alignleft class should already be in your stylesheet if you have any kind of standard WP theme, but if you don’t see it listed, add this to the end of style.css for some basic styling:
img.alignleft { float: left; }- img.size-thumbnail { padding: 10px; }
Related posts:
- First Look at WordPress 2.7
- Beginners Guide to WordPress Plugins
- WordPress 2.3.3
- Pink for October!
- WordPress 2.7 “Coltrane” Now Available!
Permalink | Leave a Comment
Copyright © Swank Web Style 2005-2009.
This feed is for personal, non-commercial use only. The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:
3218012a1d52458cc65f7ca3d7
Swank Web Style Design Studio's Notes
WordPress 2.9 “Carmen” is out!Dec 21, 2009
Secure your WordPress Blog. Upgrade Now!Sep 5, 2009
How to add Related Posts with (or without) Thumbnails to your WP BlogJul 20, 2009
WordPress 2.8.2 – Security UpdateJul 19, 2009
WordPress 2.8.1 is outJul 9, 2009
Notice to Hosting Clients: Billing issuesJul 1, 2009
WordPress 2.8 “Baker” ReleasedJun 11, 2009
WordPress 2.7.1 ReleasedFeb 11, 2009
2009 BloggiesJan 22, 2009
WordPress 2.7 “Coltrane” Now Available!Dec 10, 2008




