Smashing Magazine - we smash you with the information that will make your life easier. really.
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)
This guest post was written by Jean-Baptiste Jung, a 26-year-old blogger from Belgium, who blogs about WordPress at WpRecipes and about everything related to blogging and programming at Cats Who Code. You can stay in touch with Jean by following him on Twitter.
- 163 Comments
- 1
- 2April 15th, 2009 4:43 am
Great article!!
- 3April 15th, 2009 4:45 am
I 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.
- 4April 15th, 2009 4:50 am
This is, as usual, pure gold, top stuff!
- 5April 15th, 2009 4:50 am
Really helpful. I’ll use it for bulding templates, thanks!
- 6April 15th, 2009 4:58 am
Thanks for the info.
- 7April 15th, 2009 5:05 am
Helpfull stuff, thanks! (:
- 8April 15th, 2009 5:08 am
Another 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 :)
- 9April 15th, 2009 5:10 am
Fantastic! 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.
- 10April 15th, 2009 5:13 am
awesome post, back on form Smashing Magazine! Keep up the good work!
- 11April 15th, 2009 5:20 am
These are helpful custom solutions that really benefit an intermediate WordPress user. Thanks-a-million!
- 12April 15th, 2009 5:30 am
re: 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. - 13April 15th, 2009 5:31 am
Hi Jean, great post! I loved it!
I’m adding some of those hacks to my blog right now! lolBut 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!!
- 14April 15th, 2009 5:38 am
Hey 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
- 15April 15th, 2009 5:48 am
Just noticed that the RSS icon in the top right part of the site looks like it is in the WC. ROFL.
- 16April 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.
- 17April 15th, 2009 6:02 am
This is a really nice post, some great tips on the best way to achieve common tasks without the plugins. Thanks!
- 18April 15th, 2009 6:14 am
That’s a gr8 list. Smashing magazine articles are really useful.
- 19April 15th, 2009 6:31 am
I 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.
- 20April 15th, 2009 6:34 am
Nice list…wish you would do a similar one for Drupal or Joomla.
- 21April 15th, 2009 6:40 am
Your posts consistently rock.
- 22April 15th, 2009 6:40 am
Some interesting tips in there, thanks a lot!
- 23April 15th, 2009 6:42 am
Very useful article. Thanks for that dedicated work.
- 24April 15th, 2009 6:53 am
I 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?
- 25April 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!
- 26April 15th, 2009 7:27 am
Strange 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.
- 27April 15th, 2009 8:00 am
great 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 - 28April 15th, 2009 8:02 am
I like the tiny URL hack..thanks for the post.
- 29April 15th, 2009 8:05 am
Nothing brand new here, but still a good roundup.
Especially liked #7 Resizing images on the fly. Wish Wordpress had that built into the core!
- 30April 15th, 2009 8:06 am
Nice 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
- 31April 15th, 2009 8:07 am
Great 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!
- 32April 15th, 2009 8:13 am
Re: 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.
- 33April 15th, 2009 8:19 am
Awesome stuff! Although, I think if there was a Plugin that could do the same thing as a Hack, I’d just use the Plugin.
- 34April 15th, 2009 8:28 am
Sweet!
- 35April 15th, 2009 8:41 am
nice, 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
- 36April 15th, 2009 9:28 am
Great 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!
- 37April 15th, 2009 9:33 am
For #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.
- 38April 15th, 2009 9:37 am
Great 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!
- 39April 15th, 2009 10:00 am
Any chance we could get a new article without a number in the headline? This is linkbait gone mad!
- 40April 15th, 2009 10:35 am
Love it love it love it! For my own personal blog, I just need to find a good, free, flexible wordpress theme now.
- 41April 15th, 2009 11:18 am
What 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…
- 42April 15th, 2009 12:01 pm
Excelent 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!.
- 43April 15th, 2009 12:03 pm
this is a wonderful wonderful list! i will be using #4 Create A Maintenance Page For Your WordPress Blog!!! whoo hoo!
- 44April 15th, 2009 12:31 pm
Great information on these Wordpress hacks!
- 45April 15th, 2009 12:39 pm
Anyone 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… ;)
- 46April 15th, 2009 1:45 pm
Thanks for the awesome article. I will definitely use some of these.
- 47April 15th, 2009 2:18 pm
How could I get the tinyurl to work with tr.im’s url shortening? I cant get it to work!
- 48April 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
- 49April 15th, 2009 3:15 pm
sorry, 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;
} - 50April 15th, 2009 3:59 pm
There’s another way to temporarily take down a WordPress site very easily:
Update WordPress with Minimal Downtime - 51April 15th, 2009 6:19 pm
Nice, 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.
- 52April 15th, 2009 7:03 pm
You read my mind! I’m about to makeover my current blog template. Great article anyway..!
- 53April 15th, 2009 7:28 pm
How am I suppose to do this for my content instead of my title???
<?php the_content("Continue Reading - " . the_title('', '', false)). ""; ?> - 54April 15th, 2009 8:46 pm
Great article!!!
I tried #6 before but its not working - 55April 15th, 2009 11:03 pm
Great and helpful post. Thanks.
- 56April 15th, 2009 11:36 pm
Related Posts and Popular Posts without the plugins are great ideas!
- 57April 16th, 2009 12:09 am
Amazing 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.
- 58April 16th, 2009 12:41 am
All 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.
- 59April 16th, 2009 1:10 am
And 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;
} - 60April 16th, 2009 7:10 am
lol you call that “exceptional wordpress hacks”, i call that “some lines of code”
- 61April 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! - 62April 16th, 2009 7:56 am
why 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.
- 63April 16th, 2009 8:44 am
Your 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/
- 64April 16th, 2009 1:16 pm
I 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.
- 65April 16th, 2009 4:47 pm
Andy, 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). - 66April 16th, 2009 5:43 pm
Great article! Thank for sharing!
- 67April 17th, 2009 12:36 am
this will be great help for wordpress users and developers too for learn more advanced techniques.
Casper
- 68April 17th, 2009 2:35 am
these are some really use full ones and I have used for 1 of my clients and it saved me my time
- 69April 17th, 2009 3:43 am
Good… I’ve used in my blog Get Your Most Popular Posts Without A Plug-In with some differences
- 70April 17th, 2009 1:26 pm
Oops, 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()’.
- 71April 17th, 2009 11:38 pm
Love this post. Got some great tips here. I especially like the tip on how to disable widgets on certain pages.
- 72April 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.
- 73
- 74April 19th, 2009 3:17 am
Great hacks ..
Thanks for sharing
- 75April 19th, 2009 4:07 am
Nobody 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.
- 76April 19th, 2009 7:00 am
excelente aporte, sobre todo ese manejo de los post mas leidos y los articulos relacionados en wordpress.
- 77April 19th, 2009 7:07 am
I 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.
- 78April 19th, 2009 6:09 pm
Top notch article!! Thanks for putting this together.
- 79April 22nd, 2009 12:12 am
Has 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 image - 80April 23rd, 2009 2:19 am
Really Great and Useful WP Hacks!
I think WP should make a maintenance page like Drupal.
Thanks!
- 81May 3rd, 2009 3:45 am
For : 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/
- 82May 6th, 2009 4:02 pm
the tip four, is a good solution but is a better way use WP-Lock when you have a dynamic IP
:)
- 83May 7th, 2009 7:38 am
For 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.
- 84May 15th, 2009 10:59 am
thanks friend… need to add some of this to my site
- 85May 20th, 2009 10:15 am
Love the first hack for tinyurl, but I’d rather use it with a Snipurl/Snipr. Great article!
- 86May 21st, 2009 11:04 am
nice! i was looking for some of those for awhile. Thanks!
- 87May 27th, 2009 12:45 pm
Thanks for the great post. I’m trying to get rid of plug-ins this will help a lot.
- 88May 29th, 2009 10:33 am
Nice tips but not for complete beginners – too many security holes, great post other wi$e thanx
- 89July 21st, 2009 4:52 pm
What security holes?
- 90
- 91
- 92September 14th, 2009 12:21 pm
How 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 [...]?
- 00
There are no trackbacks at this time. If you are interested in leaving a trackback, please use this URL.
Leave a Comment
Make sure you enter the * required information where indicated. Please also rate the article as it will help us decide future content and posts. Comments are moderated – and rel="nofollow" is in use. Please no link dropping, no keywords or domains as names; do not spam, and do not advertise!
Interact
Popular
- 100 Wordpress Themes
- Photoshop Tutorials
- Fantastic Wallpapers
- 40+ Excellent Freefonts
- Dual-Screen Wallpapers
- Wordpress Themes for 2009
- Illustrator Tutorials
- Incredible Free Icon Sets
- High-Quality Free Fonts
- 30 Scripts For Galleries
- Photoshop Text Effects
- Useful Icon Sets
- Web Design Trends
- iPhone Wallpapers
- Before Launching a Website
- CSS Layouts And Templates
- Photoshop Actions
- Stunning Pictures and Photos
- Fantastic HDR Pictures
- Logo Design Tutorials
- Free Design Templates
- 10 Mistakes In Logo Design
- Photoshop Custom Shapes
- 40 Creative Design Layouts
- 8 Layout Solutions
- 53 CSS Techniques
- Photography Techniques
- Black & White Photography
- Styling Design Elements
- CSS-Based Forms
- 50 jQuery Techniques
- 50 Portfolio Websites
- 50 CSS Techniques
- Creative Logo Designs
- Desktop Wallpapers
- 25 Open Source Mac Apps
- 50 Free Icon Sets
- The Big Showcase Of Online T-Shirt Stores - http://bit.ly/5Tq8uA
- @ilmv oh ok then ;)
- @ilmv no, the SM Book will not be out of date :) We made sure it contains universal design, usability and marketing principles.
- Apple ad bombing Windows 7 on Google - http://bit.ly/28ctPq
- Atatonic - a fresh CSS framework - http://bit.ly/4oOV2w (via @umutm)
- @HrvojeKC yes, that's an interesting idea. Maybe when the waiting is over, we'll write a detailed post about it.


Nice post but most of them are really simple and the rest have already been listed on previous posts.