10 Exceptional WordPress Hacks
One of the reasons people love WordPress so much is its great flexibility. You can change the software’s appearance with themes. You can enhance its functionality with plug-ins. And, last but not least, you can totally unleash WordPress’ power with hacks. Some time ago, we wrote a post showing 10 Killer WordPress Hacks.
Today, let’s do it again with 10 new and totally killer WordPress hacks to make your blog stand out from the crowd. As usual, we won’t just list the hacks alone. In each entry, you’ll find an explanation of the code as well as the kinds of problems that the hack solves.
You may be interested in the following related posts:
- 15 Useful Twitter Hacks and Plug-Ins For WordPress
- Mastering WordPress Shortcodes
- 10 Steps To Protect The Admin Area In WordPress
- 8 Useful WordPress SQL Hacks
- 10 Useful RSS-Tricks and Hacks For WordPress
1. Create TinyURLs On The Fly

The problem. Because Twitter has become a social media revolution, many bloggers and Twitter users enjoy sharing blog posts they have found and liked on Twitter. However, manually creating a TinyURL before tweeting can get a little tedious. As you probably know, Twitter can bring a lot of traffic to your blog, so it is in your interest to consistently provide short URLs to your readers.
The solution. To use this recipe, follow the simple steps below:
- Open your functions.php file.
- Paste the following code in the file:
function getTinyUrl($url) { $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url); return $tinyurl; } - Open your single.php file and paste the following in the loop:
<?php $turl = getTinyUrl(get_permalink($post->ID)); echo 'Tiny Url for this post: <a href="'.$turl.'">'.$turl.'</a>' ?> - That’s all you need. Each of your posts now has its own TinyURL, ready for tweeting!
Code explanation. The popular URL shortening service TinyURL provides a quick API that creates TinyURLs on the fly. When you pass a URL to http://tinyurl.com/api-create.php, the API immediately prints the related TinyURL on the screen.
Using the PHP function file_get_contents(), we can get it and assign it to the $tinyurl variable. The last part of the code retrieves the post’s permalink and passes it as a parameter to the getTinyUrl() function previously created.
Source:
2. List Upcoming Posts

The problem. If you often schedule posts to be published, how about displaying them in a list? This will make your readers look forward to what you’re going to publish in a few days and can help you reach new RSS subscribers. Implementing this functionality on your WordPress blog isn’t hard at all.
The solution. Nothing hard here. Just copy this code and paste it anywhere in your theme files.
<div id="zukunft">
<div id="zukunft_header"><p>Future events</p></div>
<?php query_posts('showposts=10&post_status=future'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div >
<p class><b><?php the_title(); ?></b><?php edit_post_link('e',' (',')'); ?><br />
<span class="datetime"><?php the_time('j. F Y'); ?></span></p>
</div>
<?php endwhile; else: ?><p>No future events scheduled.</p><?php endif; ?>
</div>
Once you’ve saved the file, your upcoming posts will be displayed on your blog.
Code explanation. This code use the super-powerful query_posts() WordPress function, which allows you to take control of the WordPress loop.
The parameter used is post_status, which allows you to get posts according to their status (published, draft, pending or future). The showposts parameter is also used to define how many items you’d like to get. You can change the value of this parameter on line 4 to retrieve more or less than ten posts.
Source:
3. Create A “Send To Facebook” Button

The problem. In the first hack, we noted that Twitter can bring a lot traffic to your blog. Another website that can boost your traffic stats easily is Facebook. In this hack, let’s see how we can create a “Send to Facebook” button for your WordPress blog.
The solution.
- Open the single.php file in your theme.
- Paste the following code in the loop:
<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>" target="blank">Share on Facebook</a> - Alternatively, you could use the getTinyUrl() function to send a short URL to Facebook:
<?php $turl = getTinyUrl(get_permalink($post->ID)); ?> <a href="http://www.facebook.com/sharer.php?u=<?php echo $turl;?>&t=<?php the_title(); ?>" target="blank">Share on Facebook</a> - That’s all. Your readers will now be able to share your blog post on Facebook with their friends!
Code explanation. This useful hack is very easy to understand: the only thing we do here is retrieve the post’s permalink and title and send them as parameters to http://www.facebook.com/sharer.php.
In the alternative method, we used the getTinyUrl() function (created in the previous hack) to send a short URL instead of the post’s permalink.
Source:
4. Create A Maintenance Page For Your WordPress Blog

The problem. One thing I really like about Drupal is the option to temporarily redirect visitors to a maintenance page. Sadly, WordPress doesn’t have this feature. When you upgrade your blog, switch themes or make design changes, you may not want your visitors to see your blog as it is being tweaked, especially if it has design or code problems or, even worse, security gaps.
The solution. To solve this problem, we use the power of the .htaccess file. Just follow the steps below to get started.
- Create your maintenance page. A simple WordPress page is generally sufficient.
- Find your .htaccess file (located at the root of your WordPress installation) and create a back-up.
- Open your .htaccess file for editing.
- Paste the following code:
RewriteEngine on RewriteCond %{REQUEST_URI} !/maintenance.html$ RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123 RewriteRule $ /maintenance.html [R=302,L] - Replace 123\.123\.123\.123 on line 3 with your IP address (Don’t know it?). Make sure to use the same syntax.
- Now, all visitors except you will be redirected to your maintenance page.
- Once you’re done tweaking, upgrading, theme switching or whatever, re-open your .htaccess file and remove (or comment out) the redirection code.
Code explanation. The .htaccess file, which controls the Apache Web server, is very useful for these kinds of tasks.
In this example, we state that any visitor who has an IP different from 123.123.123.123 (which doesn’t request maintenance.html) should be redirected to maintenance.html.
By replacing 123.123.123.123 with your own IP address, you make sure you’re still allowed to browse your blog normally, while others are redirected to maintenance.html.
Source:
5. Display Related Posts Without A Plug-In

The problem. One well-known way of keeping visitors on your blog longer and helping them discover news posts is to display, usually at the end of the article, a list of related content.
Many plug-ins will do this job, but why not super-charge your theme by integrating this functionality by default?
The solution.
- Open the single.php file in your theme.
- Paste the following code in the loop:
<?php //for use in the loop, list 5 post titles related to first tag on current post $tags = wp_get_post_tags($post->ID); if ($tags) { echo 'Related Posts'; $first_tag = $tags[0]->term_id; $args=array( 'tag__in' => array($first_tag), 'post__not_in' => array($post->ID), 'showposts'=>5, 'caller_get_posts'=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> <?php endwhile; } } ?> - Save the file, and then have a look at your blog: related posts are automatically displayed!
Code explanation. This hack uses tags to retrieve related posts. The first thing it does is get the post’s tags. If a post has tags, the first one is extracted and used in a query that retrieves posts with the same tag.
By default, this code displays up to five related posts. To change this number, simply edit line 9 of the code.
Source:
6. Automatically Retrieve The First Image From Posts On Your Home Page

The problem. Many WordPress users use custom fields to display a thumbnail on their blog home page. Of course, this is a nice solution, but how about automatically retrieving the first image from a post and using it as a thumbnail?
The solution. This hack is quite easy to implement:
- Open the functions.php file in your theme.
- Paste this code in. Don’t forget to specify a default image on line 10 (in case a post of yours does not have an image).
function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = "/images/default.jpg"; } return $first_img; } - Save the functions.php file.
- On your blog home page (index.php), call the function this way to get the URL of the first image from the post:
<?php echo catch_that_image() ?>
Code explanation. The function uses the global variable $post to parse the post’s content with a regular expression. If an image is found, its URL is returned by the function. If not, the default image URL is returned.
Source:
7. Resize Images On The Fly

The problem. When you use thumbnails on your blog’s home page or even images in posts, having to manually resize them is boring and wastes a lot of time. So, why not use the power of PHP to do it?
The solution. To achieve this hack, just follow these simple steps:
- Get this script and save it on your computer (I’ll assume you’ve named it timthumb.php).
- Use an FTP program to connect to your server and create a new directory called scripts. Upload the timthumb.php file to it.
- Once done, you can display images like so:
<img src="/scripts/timthumb.php?src=/images/whatever.jpg&h=150&w=150&zc=1" alt="Screenshot" />In other words, you just call the timthumb.php file and pass your image as a parameter. The same goes for your desired width and height.
Code explanation. The timthumb.php script use the PHP GD library, which allows you to manipulate images dynamically with PHP. GD is installed by default on all servers running PHP5. If you’re not running PHP5, you’ll have to check if GD is installed before using this script.
The timthumb.php file gets the parameters you’ve passed to it (image URL, width and height) and uses it to create a new image with your stated dimensions. Once that’s done, the image is returned to you.
Source:
8. Get Your Most Popular Posts Without A Plug-In

The problem. Displaying your most popular posts is a good way to make visitors stay longer on your blog, as is displaying related posts. Many great plug-ins can list your most popular posts, but again, why use a plug-in when you can simply hack your WordPress theme to do it automatically?
The solution. Just paste the following code anywhere in your theme files (for example, in sidebar.php). To change the number of displayed posts, simply change the “5″ on line 3 to your desired number.
<h2>Popular Posts</h2>
<ul>
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">
<?php echo $title ?></a> {<?php echo $commentcount ?>}</li>
<?php } } ?>
</ul>
Code explanation. This code executes an SQL query to the WordPress database, using the $wpdb object, to get a list of the five posts with the most comments. The results are then wrapped in an unordered HTML list and displayed on screen.
Source:
9. Highlight Searched Text In Search Results

The problem. The WordPress search engine system is often criticized for not being powerful enough. One of its weakest points in my opinion is that searched text is not easily distinguishable from the rest of the text. Let’s solve that!
The solution.
- Open your search.php file and find the the_title() function.
- Replace it with the following:
echo $title; - Now, just before the modified line, add this code:
<?php $title = get_the_title(); $keys= explode(" ",$s); $title = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="search-excerpt">\0</strong>', $title); ?> - Save the search.php file and open style.css. Add the following line to it:
strong.search-excerpt { background: yellow; }
That’s all. Better, isn’t it?
Code explanation. Once again, regular expressions are a lifesaver. The regexp parses the $s content ($s is the variable containing the searched text) and automatically adds a <strong class=”search-excerpt”> element around any occurrences of $s.
Then, you simply modify your style.css file to give searched text a special style and make it more visible to your readers.
Sources:
10. Disable Widgetized Areas Without Editing Theme Files

The problem. Widgets are very useful, but sometimes you don’t need them on a particular page or post. Sure, you can create a page template for a particular page or even remove the widgetized zone from the code, but a much better and more elegant solution exists.
The solution. To do this, simply add the following code to your functions.php file:
<?php
add_filter( 'sidebars_widgets', 'disable_all_widgets' );
function disable_all_widgets( $sidebars_widgets ) {
if ( is_home() )
$sidebars_widgets = array( false );
return $sidebars_widgets;
}
?>
Code explanation. This code first adds a filter to the sidebars_widgets WordPress function. Now every time WordPress tries to execute this function, it will execute the disable_all_widgets function we just created.
The disable_all_widgets function uses WordPress conditional tags (in this example, is_home(), but you can use any conditional tag) to disable all widgets if a visitor is on a particular page or post.
Source:
Related posts
You may be interested in the following related posts:
- 15 Useful Twitter Hacks and Plug-Ins For WordPress
- Mastering WordPress Shortcodes
- 10 Steps To Protect The Admin Area In WordPress
- 8 Useful WordPress SQL Hacks
- 10 Useful RSS-Tricks and Hacks For WordPress
(al)




Kartik
April 15th, 2009 4:43 amNice post but most of them are really simple and the rest have already been listed on previous posts.
Alessandro
April 15th, 2009 4:43 amGreat article!!
Lindsay Lee
April 15th, 2009 4:45 amI am in the process of developing my personal homepage, and I am not sure if I should use WordPress or not. I have experimented with it in the past but am not sure if it is appropriate for a graphic designer/web designer/developer to use. I wonder if I should write my own PHP or use WordPress. Either way, great article, there are a lot of tools here to help with social networking.
Pete
April 15th, 2009 4:50 amThis is, as usual, pure gold, top stuff!
kiziel
April 15th, 2009 4:50 amReally helpful. I’ll use it for bulding templates, thanks!
Kevin Gilbert
April 15th, 2009 4:58 amThanks for the info.
Kathi
April 15th, 2009 5:05 amHelpfull stuff, thanks! (:
Andrea Pelizzardi
April 15th, 2009 5:08 amAnother way to do the “8. Get Your Most Popular Posts Without A Plug-In”.
http://www.andreapelizzardi.com/blog/how-to-get-the-most-commented-posts-in-wordpress/
Anyway, good article… not great :)
Dan
April 15th, 2009 5:10 amFantastic! The upcoming posts thing sure looks handy. I like to keep my flow of posts consistent but sometimes I have a million and one ideas for posts that I keep as drafts. Having this upcoming posts list is a cracker.
Jonny Haynes
April 15th, 2009 5:13 amawesome post, back on form Smashing Magazine! Keep up the good work!
David (Marketing Integrity)
April 15th, 2009 5:20 amThese are helpful custom solutions that really benefit an intermediate WordPress user. Thanks-a-million!
andy
April 15th, 2009 5:30 amre: Create TinyURLs On The Fly:
isn’t this opening a connection with tinyurl every time the page loads despite there is already a shortened url existing for the post?
and what will happen, when tinyurl.com is not available?
is the page loading then anyway?
and what about a solution using the short link provided by wp itself with the …/?p=999 format like “http : / / smashingmagazine.com / ? p=123″ ?
your twitter links wouldn’t be dependant from an external source and your domain name would be instantly visible.
Matheus Almeida
April 15th, 2009 5:31 amHi Jean, great post! I loved it!
I’m adding some of those hacks to my blog right now! lol
But I found an problem at tip #9 when I was modifying my code.
There’s a missing “$1″, so the regex keep the found word to highlight.
So, it shold look like this:
<strong class="search-excerpt">$1</strong>Thanks for the tips!!
Florian Dellé
April 15th, 2009 5:38 amHey Jean-Baptiste, very useful hacks, although I knew a few of them already from your Blogs. But anyway, it’s nice to read an article in my favourite magazine by my favourite blogger. ;-)
Thanks to you, I will have to sit down for several hours and tweak my Blog.
By the way: With so many Blogs of yours, please write an article about a good Blog-Time-Management. xD
Pandjarov
April 15th, 2009 5:48 amJust noticed that the RSS icon in the top right part of the site looks like it is in the WC. ROFL.
Daryn St. Pierre
April 15th, 2009 5:54 am@Lindsay Lee – Why re-invent the wheel though? WordPress has a huge following and the vast amount of plugins, hacks and users makes it completely worthwhile. Although making your own thing is fun.
I think this is a great article, regardless of whether or not some of them were posted elsewhere. I wasn’t aware of them and I’m sure a lot of other people weren’t either. Now they are. There are a lot of hacks here that I can actually use in everyday projects.
ErisDS
April 15th, 2009 6:02 amThis is a really nice post, some great tips on the best way to achieve common tasks without the plugins. Thanks!
Mayur
April 15th, 2009 6:14 amThat’s a gr8 list. Smashing magazine articles are really useful.
Rene
April 15th, 2009 6:31 amI do not think it would be wise to follow tip #1 as it would slow down your blog A LOT because whenever your blog gets a request WP must contact TinyURL in order to fetch the URL. The same URL, time and time again.
myDevWares
April 15th, 2009 6:34 amNice list…wish you would do a similar one for Drupal or Joomla.
Adam Kayce : Monk at Work
April 15th, 2009 6:40 amYour posts consistently rock.
William
April 15th, 2009 6:40 amSome interesting tips in there, thanks a lot!
azizbaba
April 15th, 2009 6:42 amVery useful article. Thanks for that dedicated work.
Michael
April 15th, 2009 6:53 amI always wondered which is the better option, using your own theme functions or using plugins. Is there any performance advantage to be gained either option?
Tschai
April 15th, 2009 7:18 am@andy about TinyUrls
those are some valid remarks; these issues occurs with every external service.
I’ve had my share with IntenseDebate and sometimes Google Analytics is very slow.
But your remark about WP’s build in pagenumbering might be just what I’m looking for; why bother with TinyURL indeed!
Why haven’t I thought about that myself!
Will try to implement that on my upcoming fan-tas-tic project…thnx for the tip!
James Pearce
April 15th, 2009 7:27 amStrange you didn’t mention supporting mobile.
Actually with a simple theme, you can use tinysrc.mobi to do off-server image resizing (per mobile) – and you’ve got a decent mobile blog.
Probably simple enough to warrant being called a hack.
Piet
April 15th, 2009 8:00 amgreat post, but I have seen a very similar post published 5 days earlier than this one…
http://www.catswhocode.com/blog/10-tricks-to-make-your-wordpress-theme-stand-out
wordpress blogger
April 15th, 2009 8:02 amI like the tiny URL hack..thanks for the post.
Jared
April 15th, 2009 8:05 amNothing brand new here, but still a good roundup.
Especially liked #7 Resizing images on the fly. Wish WordPress had that built into the core!
Heguiberto Souza
April 15th, 2009 8:06 amNice post, I just need to get my butt out of this malaise and start the project of creating my own page I have been postponing for so long
Vanilla Man
April 15th, 2009 8:07 amGreat tip! But you can even highlight the searched text in the excerpt. Just change the $title to $excerpt, and change get_the_title with get_the_excerpt. echo the $excerpt variable in your search results and you’re done!
BARTdG
April 15th, 2009 8:13 amRe: Display Related Posts Without A Plug-In
This is a list of links, so it would be better to make it a
<ul>.Anyway, I like the post. It makes hacking WP look so simple.
Brad
April 15th, 2009 8:19 amAwesome stuff! Although, I think if there was a Plugin that could do the same thing as a Hack, I’d just use the Plugin.
Simon
April 15th, 2009 8:28 amSweet!
lukas
April 15th, 2009 8:41 amnice, it will help me with the current project I’ve got to do. by the way, anyone interested to help me with some hacks and plugins, templates etc? there is plenty to do and I can easy give away some parts to other developer which hopefully can speed up the development. more info – priv – just email me lokers(at)gmail.com
good article! as always! thank you
Giles
April 15th, 2009 9:28 amGreat article, although, the related articles hack will not work for me. I’ve tried it on two of my many wordpress blogs. I keep getting an “Error on line __” where on the line is the ‘?php endwhile;’
What am I doing wrong? Thanks!
Devin
April 15th, 2009 9:33 amFor #4, Create A Maintenance Page For Your WordPress Blog, I use a plug-in. This is easier than manually editing the htaccess each time and allows all the admins to view the site while in maintenance.
http://wordpress.org/extend/plugins/maintenance-mode/
JORGE LINARES
April 15th, 2009 9:37 amGreat stuff here, some which I’ve been looking for and had never found them until now. Make more posts like this even if it has been posted somewhere else. Sometimes we don’t have the time to search all around the web and just like to find it here.
Even though each hack describes what they each do but it would be more helpful to show Demos of each hack.
Thanks!
cdoggyd
April 15th, 2009 10:00 amAny chance we could get a new article without a number in the headline? This is linkbait gone mad!
Preeti
April 15th, 2009 10:35 amLove it love it love it! For my own personal blog, I just need to find a good, free, flexible wordpress theme now.
TX CHL Instructor
April 15th, 2009 11:18 amWhat happens to the ‘hacks’ when you install the next WP update? Do you have to re-do all of the hacks? That could get old…
agilius
April 15th, 2009 12:01 pmExcelent article. I learned a lot from it. I am a novice wordress designer and allways wanted to know how to resize images on the fly. Thanks for this great information!.
iseethings
April 15th, 2009 12:03 pmthis is a wonderful wonderful list! i will be using #4 Create A Maintenance Page For Your WordPress Blog!!! whoo hoo!
Digital Photography
April 15th, 2009 12:31 pmGreat information on these WordPress hacks!
tschai
April 15th, 2009 12:39 pmAnyone interested in using the built-in short/default URL’s in WordPress instead of TinyURL, like stated in posts #12 and #25, you should consider this post of mine:
Need a short URL service? Try WordPress!
It works for me… ;)
Barbara
April 15th, 2009 1:45 pmThanks for the awesome article. I will definitely use some of these.
Montana Flynn
April 15th, 2009 2:18 pmHow could I get the tinyurl to work with tr.im’s url shortening? I cant get it to work!
ndy
April 15th, 2009 2:33 pm@Montana Flynn
this should work with tr.im:
function getTinyUrl($url) {
$tinyurl = file_get_contents("http://api.tr.im/api/trim_simple?url=?url=".$url);
return $tinyurl;
}
the rest stays the same
ndy
April 15th, 2009 3:15 pmsorry, this got mixed up because of the link :)
here again, change the hxxp to http :
function getTinyUrl($url) {$tinyurl = file_get_contents("hxxp://api.tr.im/api/trim_simple?url=".$url);
return $tinyurl;
}
Mark
April 15th, 2009 3:59 pmThere’s another way to temporarily take down a WordPress site very easily:
Update WordPress with Minimal Downtime
Matt
April 15th, 2009 6:19 pmNice, looks like I’ll have to add related post, popular, and might even add “Highlight Searched Text In Search Results” into themes I design from now on.
Azhar Madia
April 15th, 2009 7:03 pmYou read my mind! I’m about to makeover my current blog template. Great article anyway..!
Monie
April 15th, 2009 7:28 pmHow am I suppose to do this for my content instead of my title???
<?php the_content("Continue Reading - " . the_title('', '', false)). ""; ?>
alexandra
April 15th, 2009 8:46 pmGreat article!!!
I tried #6 before but its not working
Creamy CSS
April 15th, 2009 11:03 pmGreat and helpful post. Thanks.
Hardy
April 15th, 2009 11:36 pmRelated Posts and Popular Posts without the plugins are great ideas!
Byron Rode
April 16th, 2009 12:09 amAmazing Article, just one thing to point out, the .htaccess section (Point 4) the [R=302] flag should be changed to [R=307] – 302 redirects are VERY bad for SEO and if Google comes past at the time of that maintenance page being up, it will index that content, which is not good. Using a 307 redirect will prevent indexing of the maintenance page and tell Google to come back later.
lossendae
April 16th, 2009 12:41 amAll of that can be done with MODx, Concrete5 or EE without “hack” or php programming…
Well, that’s the difference between real CMS’s and powerful but hacked blog platform.
Jonas
April 16th, 2009 1:10 amAnd here is the code for the to.ly url shortening service:
change the hxxp to http :
function getTinyUrl($url) {
$tinyurl = file_get_contents(“hxxp://to.ly/api.php?longurl=”.$url);
return $tinyurl;
}
je_braquerai_bien_votre_compte_de_pub
April 16th, 2009 7:10 amlol you call that “exceptional wordpress hacks”, i call that “some lines of code”
Priyank Vira
April 16th, 2009 7:54 am@Lindsay Lee
Wordpress is a great tool for blogs, or even CMS. It can make your life much easier. As a web designer. graphic designer or w/e you do, I think using WordPress is much better option then creating your own blog/CMS. You can tweek WordPress backend to add functionalities you need. Good Luck!
Priyank Vira
April 16th, 2009 7:56 amwhy doesn’t Smashing Magazine add a easy functionality of replying to other people’s comments? This way commenter’s can have a good discussion going. And Subscribe to comments would be a good addition.
Sharon Vaz
April 16th, 2009 8:44 amYour post states that there is no WP plugin that exists to put the site “on maintenance mode” when you are making changes on the site. This is not true. The Maintenance Mode plugin, which has been around puts up a splash page while maintenance is being done. You can get more details about it here http://wordpress.org/extend/plugins/maintenance-mode/
Louis
April 16th, 2009 1:16 pmI think Smashing Magazine needs a better “comments” plugin… The number of comments displayed at the top of the article does not match the number of comments that are actually displayed. Is it counting pending ones? That would be quite odd… Does WP always do that?
@Sharon: Good find on the Maintenance Mode plugin.
garrick Van Buren
April 16th, 2009 4:47 pmAndy, I wrote up a quick WordPress hack to make short URLs that are native to your blog: http://garrickvanburen.com/archive/wordpress-url-shortening-hack
It’s 2 lines of code (one in the htaccess file and one in your templates file).
mrgiaiphapso
April 16th, 2009 5:43 pmGreat article! Thank for sharing!
dzinepress
April 17th, 2009 12:36 amthis will be great help for wordpress users and developers too for learn more advanced techniques.
Casper
vijay
April 17th, 2009 2:35 amthese are some really use full ones and I have used for 1 of my clients and it saved me my time
piervix
April 17th, 2009 3:43 amGood… I’ve used in my blog Get Your Most Popular Posts Without A Plug-In with some differences
andol Li
April 17th, 2009 1:26 pmOops, the ‘Display Related Posts Without A Plug-In’ part has a bug which will change the comment form’s performance if it is put right before the ‘comment_template()’.
sylvia
April 17th, 2009 11:38 pmLove this post. Got some great tips here. I especially like the tip on how to disable widgets on certain pages.
Liza
April 18th, 2009 6:01 am#5 – you have error in the code, it won’t work like that, there is a bit more code to be added, just like in the link you provided.
abed el salam
April 18th, 2009 7:34 pmWow,Thanks
Link
Steen Öhman
April 19th, 2009 3:17 amGreat hacks ..
Thanks for sharing
lokers
April 19th, 2009 4:07 amNobody noticed that “5. – related posts” will actually throw error? Did you guys test it at all before publishing on the site? Besides, even if you add this extra } it won’t print anything at all cos the code is not complete. Anyway, I like the article, well done.
Juan José
April 19th, 2009 7:00 amexcelente aporte, sobre todo ese manejo de los post mas leidos y los articulos relacionados en wordpress.
TheGreyMan
April 19th, 2009 7:07 amI think tips like these are really useful for us designers who code, whereas for developers maybe less so. It depends on your own needs. Personally, I love this kind of short and sweet guide which tell you exactly how to accomplish a specific task in an efficient manner. So thanks Jean-Baptiste. Nice work.
I’m with you, @cdoggyd, it’s getting a bit silly now. And how many other blogs have followed suit?!?
And by the way, @Sharon and others, there is more than one WP plug-in to put your blog in suspended animation.
Mark
April 19th, 2009 6:09 pmTop notch article!! Thanks for putting this together.
anima
April 22nd, 2009 12:12 amHas anyone noticed that on point 6 – “Automatically Retrieve The First Image From Posts On Your Home Page” the code has an error on line number 9 where it says
if(emptyempty($first_img)){ //Defines a default imageshould be
if(empty($first_img)){ //Defines a default imageDesign was here
April 23rd, 2009 2:19 amReally Great and Useful WP Hacks!
I think WP should make a maintenance page like Drupal.
Thanks!
inztinkt
May 3rd, 2009 3:45 amFor : 6. Automatically Retrieve The First Image From Posts On Your Home Page
Just keep in mind that if you are showing a lot of articles on a page (on your home page for example), this searching through your articles will cause a delay on page load and can cause complaints from your provider if you’re on shared hosting.
What i did was create an extra field to which this function can save the URL. if the extra field exists on the next load, it wont have to scan through all the text… saving resources and time :)
More info : http://inztinkt.com/blog/2009/05/03/getting-first-image-from-wordpress-post-without-killing-your-server/
Carlos Varela
May 6th, 2009 4:02 pmthe tip four, is a good solution but is a better way use WP-Lock when you have a dynamic IP
:)
Joshua Unseth
May 7th, 2009 7:38 amFor those of you wanting to integrate TimThumb with this code, you can find working code at Spidermarket’s Retrieve a Post’s First Image and Resize it with TimThumb. It’s a modification of the code found on WP Recipes’How to: Get the first image from the post and display it.
Zeqox
May 15th, 2009 10:59 amthanks friend… need to add some of this to my site
LodMerci
May 20th, 2009 10:15 amLove the first hack for tinyurl, but I’d rather use it with a Snipurl/Snipr. Great article!
Fechy
May 21st, 2009 11:04 amnice! i was looking for some of those for awhile. Thanks!
StetE
May 27th, 2009 12:45 pmThanks for the great post. I’m trying to get rid of plug-ins this will help a lot.
Hilary
May 29th, 2009 10:33 amNice tips but not for complete beginners – too many security holes, great post other wi$e thanx
consacepo
August 22nd, 2009 1:50 pmTop notch article!! Thanks for putting this together.
consacepo
consacepo
August 22nd, 2009 1:53 pmTop notc h article!! Tha nks for putting this togeth er.
consacepo
Kenneth
September 14th, 2009 12:21 pmHow do I change so my search result once again starts displaying “read more” instead of [...], I have that function in my functions-file, and before I applied that hack it worked fine, but now once again shows [...]?
Ricky
December 28th, 2009 8:33 pmWell. I did try related posts hack for my website. But the problem is it shows comment that is not related to post, infact it shows the comments related to last related post. i.e if my article is on java twitter mobile apps. and i have two related posts x and y then it will show the comments of y post instead of “java twitter mobile apps”. I guess it is a problem with looping. I’m placing it in wrong place or something else?
Adriaan Fenwick
December 29th, 2009 1:22 amThanks, this has really been helpful in the development of my new blog.
JP
January 26th, 2010 10:13 pmThe related articles snippet is bugged. When I apply it to my post it takes the comments from another article and places it in an incorrect article.
jesse
May 22nd, 2010 8:07 amGreat post.. I’ve used a number of these examples and they work great!
One question, if you wanted to add a ‘Hot’ or ‘Popular’ image to your top 10 most popular posts.. what would be the best snippet to do that with ???
So, when a visitors is viewing one of the top 10 most popular posts, a div is shown (I’ll then use CSS to style the div, etc.)