Smashing Magazine - we smash you with the information that will make your life easier. really.
10 Killer WordPress Hacks
by Jean-Baptiste Jung
2008 was a very good year for the WordPress community. The software was updated numerous times, leading to the recent release of version 2.7, and many new blogs dedicated to WordPress were created. Of course, tons of new hacks were discovered, which helped lots of bloggers enhance their blogs.
In this article, we’ll show you 10 new useful killer WordPress hacks to unleash the power of your favorite blogging engine. Each hack has an accompanying explanation, so you’ll not only unleash the power of WordPress but also understand how it works.
You may be interested in the following related articles as well:
[Offtopic: by the way, did you know that Smashing Magazine has one of the most influential and popular Twitter accounts? Join our discussions and get updates about useful tools and resources — follow us on Twitter.]
1. Display AdSense Ads to Search Engines Visitors Only

The problem. It’s a known fact that regular visitors don’t click on ads. Those who do click on ads are, 90% of the time, visitors coming from search engines.
Another problem is Google’s “smart pricing.” Being smart priced means that your click-through rate (CTR) is low and the money you earn per click is divided by between 2 and 10. For example, if a click would normally earn you $1.00, with smart pricing it could earn you as little as $0.10. Painful, isn’t it? Happily, this solution displays your AdSense ads to search engine visitors only, which means more clicks and a higher CTR.
The solution.
- Open the functions.php file in your theme.
- Paste the following code in it:
function scratch99_fromasearchengine(){ $ref = $_SERVER['HTTP_REFERER']; $SE = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.'); foreach ($SE as $source) { if (strpos($ref,$source)!==false) return true; } return false; } - Once done, paste the following code anywhere in your template where you want your AdSense ads to appear. They’ll be displayed only to visitors coming from search engine results:
if (function_exists('scratch99_fromasearchengine')) { if (scratch99_fromasearchengine()) { INSERT YOUR CODE HERE } }
Code explanation. This hack starts with the creation of a function called scratch99_fromasearchengine(). This function contains a $SE array variable in which you can specify search engines. You can easily add new search engines by adding new elements to the array.
The scratch99_fromasearchengine() then returns true if the visitor comes from one of the search engines containing the $SE array variable.
Sources:
2. Avoid Duplicate Posts in Multiple Loops

The problem. Due to the recent popularity of “magazine” themes, there’s a high demand from WordPress users who use more than one loop on their blog home page for a solution to avoiding duplicate posts on the second loop.
The solution. Here’s a simple solution to that problem, using the power of PHP arrays.
- Let’s start by creating a simple PHP array, and put all post IDs from the first loop in it.
<h2>Loop n°1</h2> <?php $ids = array(); while (have_posts()) : the_post(); the_title(); ?> <br /> <?php $ids[]= $post->ID; endwhile; ?>
- Now, the second loop: we use the PHP function
in_array()to check if a post ID is contained in the$idsarray. If the ID isn’t contained in the array, we can display the post because it wasn’t displayed in the first loop.<h2>Loop n°2</h2> <?php query_posts("showposts=50"); while (have_posts()) : the_post(); if (!in_array($post->ID, $ids)) { the_title();?> <br /> <?php } endwhile; ?>
Code explanation. When the first loop is being executed, all IDs of posts contained within it are put into an array variable. When the second loop executes, we check that the current post ID hasn’t already been displayed in the first loop by referring to the array.
Source:
3. Replacing “Next” and “Previous” Page Links with Pagination

The problem. By default, WordPress has functions to display links to previous and next pages. This is better than nothing, but I don’t understand why the folks at WordPress don’t build a paginator by default. Sure, there are plug-ins to create pagination, but what about inserting it directly in your theme?
The solution. To achieve this hack, we’ll use the WP-PageNavi plug-in and insert it directly in our theme.
- The first thing to do, obviously, is download the plug-in.
- Unzip the plug-in archive on your hard drive, and upload the wp-pagenavi.php and wp-pagenavi.css files to your theme directory.
- Open the file that you want the pagination to be displayed in (e.g. index.php, categories.php, search.php, etc.), and find the following code:
<div class="navigation"> <div class="alignleft"><?php next_posts_link('Previous entries') ?></div> <div class="alignright"><?php previous_posts_link('Next entries') ?></div> </div>Replace this part with the code below:
<?php include('wp-pagenavi.php'); if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>- Now we have to hack the plug-in file. To do so, open the wp-pagenavi.php file and find the following line (line #61):
function wp_pagenavi($before = '', $after = '') { global $wpdb, $wp_query;We have to call the
pagenavi_init()function, so let’s do it this way:function wp_pagenavi($before = '', $after = '') { global $wpdb, $wp_query; pagenavi_init(); //Calling the pagenavi_init() function - We’re almost done. The last thing to do is to add the wp-pagenavi style sheet to your blog. To do so, open up header.php and add the following line:
<link rel="stylesheet" href="<?php echo TEMPLATEPATH.'/pagenavi.css';?>" type="text/css" media="screen" />
Code explanation. This hack mostly consists of simply including the plug-in file directly in the theme file. We also had to add a call to the pagenavi_init() function to make sure the pagination would be properly displayed.
Source:
4. Automatically Get Images on Post Content

The problem. Using custom fields to display images associated with your post is definitely a great idea, but many WordPress users would like a solution for retrieving images embedded in the post’s content itself.
The solution. As far as we know, there’s no plug-in to do that. Happily, the following loop will do the job: it searches for images in post content and displays them on the screen.
- Paste the following code anywhere in your theme.
<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <?php $szPostContent = $post->post_content; $szSearchPattern = '~<img [^\>]*\ />~'; // Run preg_match_all to grab all the images and save the results in $aPics preg_match_all( $szSearchPattern, $szPostContent, $aPics ); // Check to see if we have at least 1 image $iNumberOfPics = count($aPics[0]); if ( $iNumberOfPics > 0 ) { // Now here you would do whatever you need to do with the images // For this example the images are just displayed for ( $i=0; $i < $iNumberOfPics ; $i++ ) { echo $aPics[0][$i]; }; }; endwhile; endif; ?>
Code explanation. The above code basically consists of a simple WordPress loop. The only difference is that we use PHP and regular expressions to search for images within the post’s content instead of simply displaying posts. If images are found, they’re displayed.
Sources:
- Manipulate images from WordPress post content with regular expressions
- How to: Retrieve images in post content
5. Create a “Send to Twitter” Button

The problem. Are you on Twitter? If so, we’re sure you know how good this service is for sharing what you find interesting online with your friends. So, why not give your readers a chance to directly send your posts’ URLs to Twitter and bring you some more visitors?
The solution. This hack is very simple to achieve. The only thing you have to do is to create a link to Twitter with a status parameter. Because we’re using a WordPress blog, we’ll use the function the_permalink() to get the page URL:
<a href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>" title="Click to send this page to Twitter!" target="_blank">Share on Twitter</a>
Pretty easy, isn’t it? But pretty useful too, in our opinion.
Source:
Related plug-in:
6. Using Normal Quotes Instead of Curly Quotes

The problem. If you’re a developer who often publishes code snippets on your website, you have probably encountered the following problem: a user tells you that the code you posted doesn’t work. Why? Simply because, by default, WordPress turns normal quotes into so-called “smart quotes,” which breaks code snippets.
The solution. To get rid of theses curly quotes, proceed as follows:
- Open the functions.php file in your theme. If that file doesn’t exist, create it.
- Paste the following code:
<?php remove_filter('the_content', 'wptexturize'); ?> - Save the file, and say goodbye to broken code snippets!
Code explanation. The wptexturize() function automatically turns normal quotes into smart quotes. By using the remove_filter() function, we tell WordPress that we don’t want this function to be applied to a post’s content.
Source:
7. Deny Comment Posting to No Referrer Requests
The problem. Spam is a problem for every blogger. Sure, Akismet is there to help, but what about preventing spam just a bit more? The following code will look for the referrer (the URL from where the page was called) when the wp-comments-post.php file is accessed. If a referrer exists, and if it is your blog’s URL, the comment is allowed. Otherwise, the page will stop loading and the comment will not be posted.
The solution. To apply this hack, simply paste the following code into your theme’s function.php file. If your theme doesn’t have this file, just create it.
function check_referrer() {
if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == “”) {
wp_die( __('Please enable referrers in your browser, or, if you\'re a spammer, bugger off!') );
}
}
add_action('check_comment_flood', 'check_referrer');Source:
8. Using CSS Sliding Doors in WordPress Navigaton

The problem. The built-in wp_list_pages() and wp_list_categories() functions allow lots of things, but they do not allow you to embed a <span> element so that you can use the well-known CSS sliding-doors technique. Happily, with some help from PHP and regular expressions, we can use this awesome technique on a WordPress blog.
Due to the number of tutorials on CSS sliding doors, we’re not going to explain how it works here; consider reading this excellent article if you need to know more about the technique. To view a live demo of this example, click here and refer to the main menu.
- Create the images you need, and then edit the style.css file in your WordPress theme. Here is an example:
#nav a, #nav a:visited { display:block; } #nav a:hover, #nav a:active { background:url(images/tab-right.jpg) no-repeat 100% 1px; float:left; } #nav a span { float:left; display:block; } #nav a:hover span { float:left; display:block; background: url(images/tab-left.jpg) no-repeat 0 1px; } - Now it is time to edit the header.php file. Simply copy and paste one of the following codes, according to your needs:To list your pages:
<ul id="nav"> <li><a href="<?php echo get_option('home'); ?>/"><span>Home</span></a></li> <?php echo preg_replace('@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>@i', '<li$1><a$2><span>$3</span></a>', wp_list_pages('echo=0&orderby=name&exlude=181&title_li=&depth=1')); ?> </ul>To list your categories:
<ul id="nav"> <li><a href="<?php echo get_option('home'); ?>/"><span>Home</span></a></li> <?php echo preg_replace('@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>@i', '<li$1><a$2><span>$3</span></a>', wp_list_categories('echo=0&orderby=name&exlude=181&title_li=&depth=1')); ?> </ul>
Code explanation. In this example, we make use of the echo=0 parameter in the wp_list_pages() and wp_list_categories() functions, which allows you to get the result of the function without directly printing it on the screen. Then, the result of the function is used by the PHP preg_replace() function and finally displayed with <span> tags added between the <li> and <a> tags.
Source:
9. Display a Random Header Image on Your WordPress Blog

The problem. This is not really a problem, but many WordPress users would love to be able to display a random header image to their readers.
The solution.
- Once you have selected some images to be your header images, name them 1.jpg, 2.jpg, 3.jpg and so on. You can use as many images as you want.
- Upload the images to your wp-content/themes/yourtheme/images directory.
- Open header.php and paste the following code in it:
$num = rand(1,10); //Get a random number between 1 and 10, assuming 10 is the total number of header images you have <div id="header" style="background:transparent url(images/.jpg) no-repeat top left;">
- You're done! Each page or post of your blog will now display a random header image.
Code explanation. Nothing hard here. We simply initialized a $num variable using the PHP rand() function to get a random number between 1 and 10. Then, we concatenate the result of the $num variable to the path of the theme we are using.
Source:
10. List Your Scheduled Posts

The problem. Like many bloggers, you probably want your readers to visit your blog more often or subscribe to your RSS feed. A good way to make them curious about your future posts is by listing the titles of your scheduled posts.
The solution. Open any of your theme files and paste the following code:
<?php
$my_query = new WP_Query('post_status=future&order=DESC&showposts=5');
if ($my_query->have_posts()) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><?php the_title(); ?></li>
<?php endwhile;
}
?>Code explanation. In this code, we have created a custom WordPress query using the WP_Query class to send a database query and fetch the five most recent scheduled posts. Once done, we use a simple WordPress loop to display the posts' titles.
Sources:
Related posts
You may be interested in the following related articles as well:
(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.
- 127 Comments
- 1
- 2
January 7th, 2009 12:02 pmI’ve seen some of these but overall great top 10 list!
- 3
January 7th, 2009 12:03 pmEnjoyed that article, really good read. Thanks very much.
- 4
January 7th, 2009 12:04 pmgood stuff SM! Thanks and keep smashing!
- 5
January 7th, 2009 12:14 pmGreat post… Really enjoyed this article. Would love to see more in the same vein. Perhaps a top 10 list for advanced WordPress development.
- 6
January 7th, 2009 12:15 pmGreat article. Have definately been looking for some of the above in my projects.
- 7
January 7th, 2009 12:24 pmDefinitely not the “norm” for WP hacks, very nicely done guys! Thanks, I am going to throw in that comment referrer one right now.
- 8
January 7th, 2009 12:24 pmAwesome – especially the pagination part. Will definitely utilize this in all future projects.
- 9
January 7th, 2009 12:35 pmactually, there’s a plugin for creathumb thumbnails in whaterever sizes and forms you like, using the options panel or php code embeded within the theme files…
Look for it at http://wordpress.org/extend/plugins/alakhnors-post-thumb/
- 10
January 7th, 2009 12:36 pmThis is mad.. all 10 hacks is what i want!!..
THanks so much… I gonna apply them all when i’m free..
- 11
January 7th, 2009 12:40 pmJust to say this post is excellent !
Really good work.
Thanks very much - 12
January 7th, 2009 12:49 pmThat No.1 item is fantastic, will it work on a non-wordpress page?
- 13
January 7th, 2009 12:53 pmMuch appreciated.
These are some great additions.
- 14
January 7th, 2009 12:54 pmYou can display images from recent posts with the Visual Recent Posts plugin. It allows you to achieve an effect much like you have displayed here. Granted, your code is pretty simple.
- 15
January 7th, 2009 12:57 pmgreat tuts!
look, on the first hack…
I CAN’T INCLUDE THE GOOGLE ADSENSE CODE
INSIDE THE PHP FUNCTION…i get a syntax errror…
any tip? i just paste the google adsense code as the tut says
- 16
January 7th, 2009 12:59 pmAgree with Eddy. Number one is great, it is like Chitika…
- 17
January 7th, 2009 1:00 pmAnd 10 killer Drupal hacks?
- 18
January 7th, 2009 1:03 pmAwesome hacks, wordpress ones are always much appreciated :-)
- 19
January 7th, 2009 1:11 pmWicked post Smashing. I love it!
- 20
January 7th, 2009 1:26 pmGood tips. A lot of these are really helpful.
There’s a few code errors in step 9, though:
$num = rand(1,10); //Get a random number between 1 and 10, assuming 10 is the total number of header images you have
<div id=”header” style=”background:transparent url(images/.jpg) no-repeat top left;”>The $num variable doesn’t show up in the header image url and the opening left carrot of your div tag got converted to an html entity.
- 21
January 7th, 2009 1:31 pmVery good post! But of trouble with the AdSense hack, but that was mostly because of a botched plugin-install I had previously. Keep up the good work!!
- 22
January 7th, 2009 1:31 pmsomething wrong with the rss feed for this post. Only got the html code.
Good post!
- 23
January 7th, 2009 2:18 pmAwesome post. WP Recipes rocks!
- 24
January 7th, 2009 2:28 pm7. Is a very bad idea. There are quite a few firewalls that block the referrer so you could block with that good users. Just install Norton Internet Security and you’ll get my point.
I once developed an important feature into a website based on the referrer, until I started to get messages from people that got stuck, lost data because were not automatically redirected as they should have been.
Later it turned out that quite a few people had different firewalls that were “erasing” their referrer.
This is one of those: “Kids, do not try this at home! No really, don’t!”
- 25
January 7th, 2009 2:39 pmThis is what I’m talking about! Thanks for the 10 great killer tips SmashingMag! You’re awesome
- 26
January 7th, 2009 2:48 pmHow to: Display adsense to search engines visitors only
Anyone wants to confirm that its better?
- 27
January 7th, 2009 2:55 pmAlso, will it show ads to reddit, digg , stumbleupon and other new users?
- 28
January 7th, 2009 2:57 pmThanks..I love these!
- 29
January 7th, 2009 3:01 pmNice Plugin – for #4 (4. Automatically Get Images on Post Content):
http://www.alakhnor.com/post-thumb/?cat=61 - 30
January 7th, 2009 3:40 pmYou don’t need SPAN for sliding doors, just A and LI, which WP includes already. Thank goodness for web standards and markup elegance, right?
- 31
January 7th, 2009 3:49 pmThank you for this list. Helpful for me. I’m a new follower.
- 32
January 7th, 2009 4:19 pmawesome!!!
- 33
January 7th, 2009 4:34 pmSmashing Magazine ,,, Your rocks , I like this web
We need more for this and thanks for this great site , I really like it - 34
January 7th, 2009 5:03 pmWhat can I say….. This post is awesome.
- 35
January 7th, 2009 5:30 pmI’d like to see the option to open your Flickr account from inside wp-admin. I hate going back and fourth with copying the embed code, and I don’t care for Flickr’s post to blog option. Anyone know of a plugin that does such?
- 36
January 7th, 2009 6:17 pmYeah, I was going to also mention that #9 is jacked up.
- 37
January 7th, 2009 7:08 pmit is very useful !
———-http://dress08.com———–
- 38
January 7th, 2009 7:27 pmThank you, thank you and thank you… I really liked it…
- 39
January 7th, 2009 7:31 pmThese are supreme hacks!
- 40
January 7th, 2009 7:46 pmYa man cheers! Thank you so much for sharing. Now i can work on towards my project ever since i got laid off! Cheers man
http://www.jobstaxi.com - 41
January 7th, 2009 7:47 pmGreat post, thank you! Keep going then!!!
- 42
January 7th, 2009 8:12 pmOMG dude, insane! Totally insane. Gotta love it dude.
- 43
January 7th, 2009 8:23 pm7. Deny Comment Posting to No Referrer Requests in this for the people who directly landed on the website couldn’t comment on the topic.. isn’t it.
vinoth kumar
http://www.ehotdiscussion.com - 44
January 7th, 2009 8:28 pmListing future posts is an absolutely brilliant idea!
- 45
January 7th, 2009 8:53 pmFor tip 1, the Who Sees Ads plugin can show ads only to visitors from search engines, plus a whole lot more options:
http://planetozh.com/blog/my-projects/wordpress-plugin-who-sees-ads-control-adsense-display/
- 46
January 7th, 2009 9:43 pmInspiring post, useful for me but point no. 5 “Create a “Send to Twitter” Button” maybe completed with another social bookmarking (digg, delicious and stumbleupon) as they are having strong market today. Nice.
- 47
January 7th, 2009 11:05 pmWow, very nice! I especially liked the ‘Share on Twitter’ hack!
- 48
January 7th, 2009 11:19 pmThanks for the #3 and #5
Really really really much appreciated
Congrats!Edu @ http://www.verblogargia.com.br
Twitter: @woetter - 49
January 7th, 2009 11:30 pmWow ! This is a very good post with useful hacks… I will try them on my personal website running WordPress for sure !
- 50
January 7th, 2009 11:40 pmGood~~ Great article, really useful!!!
- 51
January 7th, 2009 11:45 pmCorrect me if I’m wrong, but #1 (step 3) seems to be wrong.
It says to add this anywhere in the template
if (function_exists('scratch99_fromasearchengine')) {
if (scratch99_fromasearchengine()) {
INSERT YOUR CODE HERE
}}
This produced errors when I tried to do it, so after messing around a bit, I found this to work in my case: (except with no space between ‘<’ and ‘?php)
Insert Code Here
This may have been due to me trying to add it to the template wrong, since I don’t really know php, but that worked for me for at least adding it when it should. However, right now it works from google search directly to my blog, but not from google images in the page preview (for context of image). Any help with this would be appreciated. - 52
January 7th, 2009 11:53 pmActually I figured it out…it was just all in where I placed the code…duh.
And my last comment got messed up. What I meant to put up there: [with "(nospace)" removed]
WELCOME EARTHLIN.
- 53
January 7th, 2009 11:57 pmHello fellow Belgian WP-guy, great tips & hacks !
Some very useful techniques on display here. keep ‘em coming.
greetz,
ToM. - 54
January 8th, 2009 12:00 amgah, this is annoying. ;) My fix was to add “” to the end of those lines, and the same thing with the end }} brackets.
- 55
January 8th, 2009 12:03 amFor the 4th point(Automatically Get Images on Post Content), there is a plugin called ‘AutoFields Wordpress Plugin‘ that will auto fill the Excerpt and add an Image custom field based on the data you entered into the contents editor.
- 56
- 57
January 8th, 2009 12:35 amThere’s an error with links to the article “8 Useful Wordpress SQL Hacks”.
- 58
January 8th, 2009 12:56 amthank you! this is one of the best + useful Wordpress articles I’ve read in a while. Much appreciated and look forward to more like this ;)
- 59
January 8th, 2009 1:20 amSome really good ‘PIMPIN’ material for my blog. TNX!
- 60
January 8th, 2009 1:43 amAbout : 6. Using Normal Quotes Instead of Curly Quotes
With tag ‹code›, you don’t need to use it !
See :
“Without ‹code›”
"with ‹code›"Nice, isn’t it ? :)
Hum… Not very obvious in this comment, but just try in a post, it works !
- 61
January 8th, 2009 2:18 amYou just saved my life. Thanks!
Awesome collection of tricks. - 62
January 8th, 2009 3:09 amNice! Another helpful post I’ve found here. Great for newbies in Wordpress-related coding, like me. ;)
- 63
January 8th, 2009 3:58 amHack number 5 applied to my blog!
http://www.geeks3d.com
Will try hack # 9 later. - 64
January 8th, 2009 4:02 amThe link to “Useful Wordpress SQL Hacks” is wrong.
- 65
January 8th, 2009 4:03 amDoes anyone know of a good popular posts plugin or hack that works with 2.7? The popularity contest plugin doesn’t seem to work with the latest version of Wordpress.
Cheers.
- 66
January 8th, 2009 4:39 amI will try a lot of them on my blog, but the schedule hack does give away too much in my opinion, because it lists every entry and is not selective.
- 67
January 8th, 2009 5:06 amFor getting post images automatically there’s also the “Get the Image” Plugin by Justin Tadlock: http://justintadlock.com/archives/2008/05/27/get-the-image-wordpress-plugin.
Great post, by the way!
- 68
January 8th, 2009 5:32 ampowerfull art!
Thx very much!
- 69
January 8th, 2009 6:14 amIt is possible to automatically get images related to the post content, simply download the Zemanta plugin for Firefox. It integrates with your wordpress editor and searches automatically for images. I think it also works with blogger etc.
- 70
January 8th, 2009 6:15 amExcelent!
- 71
January 8th, 2009 6:25 amI don’t know much about Wordpress, but I would wonder if no. 9 works…
$num = rand(1,10); //Get a random number between 1 and 10, assuming 10 is the total number of header images you have
<div id="header" style="background:transparent url(images/.jpg) no-repeat top left;">
i would insert $num like here:
$num = rand(1,10); //Get a random number between 1 and 10, assuming 10 is the total number of header images you have
<div id="header" style="background:transparent url(images/$num.jpg) no-repeat top left;">Please correct me if I’m wrong. Great article btw.
- 72
January 8th, 2009 6:58 amDang, these are awesome. Usually there’s only one or two out of ten that I’d use, or haven’t seen before – but this list rocks. I implemented at least 7 of them right away.
Thanks!
- 73
January 8th, 2009 7:22 amAnother great WP post.
I’ve been using the Get Post Image plugin: http://www.andrewgrant.org/get-post-image
It’s not perfect, but it does an admirable job. I’ll definitely be giving this loop a shot.
- 74
January 8th, 2009 8:29 amI have some more anti-spam tricks I use on my blog
http://jivebay.com/2008/02/10/wordpress-spam-prevention-hack/I have a few other tips I keep secret, because the spammers like to keep an eye out for ways to get around anti-spam measures
- 75
January 8th, 2009 8:34 amSmashing!
Kinda makes me wish I didn’t just use wordpress.com for my blog ;) - 76
January 8th, 2009 8:48 amI’ve seen a lot of “Killer WordPress Hacks” type posts — but this one is HAWT! :D
- 77
January 8th, 2009 8:55 amSliding doors can work without the span. Other than that great stuff here, thanks SM!
- 78
January 8th, 2009 9:27 amreally killer!
- 79
January 8th, 2009 9:56 amGreat article. Just wanted to add an article to the list that explains not only how to use Sliding Doors in your menu in a much easier way but also how to make the current page highlighted at the same time:
Highlight current page in WordPress menus
Josh
- 80
January 8th, 2009 10:36 amyour link: 8 Useful Wordpress SQL Hacks
is broken——
thank you, kzutter, fixed it! (the SM link editor) - 81
January 8th, 2009 11:51 amDamn, this list is pretty valuable. You just got a new reader. More of this stuff! Just great.
- 82
January 8th, 2009 12:06 pmfor #2 this works as well (to start a new loop that skips the already displayed posts):
?php query_posts("showposts=10&offset=1"); //nr of posts to show and where to start
while (have_posts()) : the_post();
//do your thing - 83
January 8th, 2009 12:27 pmThank you for the pagination!
- 84
January 8th, 2009 2:24 pmI have two comments about the pagination tip…
1.There is apparently a stupid padding issue with the pagenavi plugin… It hardcodes
& #8201;spaces into the links. Anyone who has the same problem will want to go into wp-pagenavi.php and remove all of them. Not a big deal, but I read elsewhere that IE has trouble with it. I don’t know much about writing plugins, but silly things like this lead me to believe the plugin may be poorly written in general… Just a thought.2. I’m trying to edit the pagination at the bottom to say “1 of 2″ (as opposed to “Page 1 of 2″). I’ve been scrounging around in wp-pagenavi.php and I can’t figure it out. Any suggestions?
Great tips! thanks
- 85
January 8th, 2009 2:35 pmThough great for understanding WordPress, I’d like to caution against hacks. Try to find a plugin, which can be easily deactivated.
For instance, the Twitter hack, though neat, is unnecessary (unless you’re a blog that’s all about Twitter!). Instead install the Add to Any Share/Save/Bookmark plugin, which has everything (100+?) in one dropdown button menu. http://wordpress.org/extend/plugins/add-to-any/ Oh and it’s smart too, so if your visitor uses Twitter, it shows up first in the menu!
There are plenty of other plugins out there and it would not be a surprise if most of these hack are in plugin form: http://wordpress.org/extend/plugins/
- 86
January 8th, 2009 2:41 pm@ Jon Yoder:
Could you be more specific. I can’t figure it out.
- 87
January 8th, 2009 3:09 pmWhen I click on the link for ‘8 Useful Wordpress SQL Hacks’ at the end of your article, it prompts me for a username/password. Can you please fix that? Thank you.
- 88
January 8th, 2009 4:47 pmWonderful Tips
- 89
January 8th, 2009 7:07 pmnice post…tq..
- 90
January 8th, 2009 9:47 pmWow, this is a great post! I’ll definitely look into using a few of these when I start working on customizing my blog – especially the CSS sliding doors!
- 91
January 9th, 2009 12:51 amNice list of hacks.
Thanks for yet another great post. - 92
January 9th, 2009 1:37 amGreat Article … We r expecting more such cool hacks …
- 93

- 94
January 9th, 2009 5:34 amif (function_exists(’scratch99_fromasearchengine’)) {
if (scratch99_fromasearchengine()) {
INSERT YOUR CODE HERE
}
}Doesn’t this needs to be wrapped with <.?php en stuff..?
It doesnt work on my site if i add my google adsense code in the INSERT CODE HERE place. - 95
January 9th, 2009 7:02 amReally useful info, especially about the twitter ones – I’ve been wondering about that for a while, tho might add that addon to my site!
Oh, the link to ‘8 Useful Wordpress SQL Hacks ‘ leads to a wp-edit page ;) Best sort that out!
- 96
January 9th, 2009 8:45 amThis is a great article! I am still so new to WP that I am afraid to try some of these out. The main one I have been wanting is #3. Thanks!
- 97
January 9th, 2009 9:00 amwon’t there be any issue with the adsense ToS if the tip no.1 is followed and done?
- 98
January 9th, 2009 6:03 pmOnce again, a very nice collection of WordPress hacks and codes!
- 99
January 10th, 2009 3:18 amTnx Smashing for compiling them… Some this hacks are useful. Cheers!
- 100
January 10th, 2009 10:16 amIf you use the code tag, which is what it’s for, you don’t have to worry about your curly quotes hack.
- 101
January 10th, 2009 12:09 pm#8 is a bit misleading — you can still use the sliding doors method for the wp_list_pages(…) method call. WordPress assigns two classes to help the designer style the nav with the following: class=”page_item current_page_item”. See also: http://codex.wordpress.org/Template_Tags/wp_list_pages#Markup_and_styling_of_page_items
A designer worth his salt will be able to do this.
- 102
January 10th, 2009 1:10 pmSimply fantastic!! Thank you :)
- 103
January 10th, 2009 3:45 pmyou forgot to add $num into image path in #9
- 104
January 11th, 2009 1:52 amNabbed some of these hacks for my own blog. Great list.
- 105
January 11th, 2009 10:53 amBe aware! Tip #1 is using the referer without any validation. If you use it as it is, your blog is wide open for any hacker out there.
- 106
- 107
January 12th, 2009 12:54 pmHack number 1 does not work for me. I write the following
<?php if (function_exists('scratch99_fromasearchengine')) {
if (scratch99_fromasearchengine()) {
google_ad_client = "pub-3xxxxxx"; google_ad_slot = "xxxxxxx"; google_ad_width = 468; google_ad_height = 60; }} ?>and for some reason Dreamweaver doesn’t show the last “?>” in red as usual and I get a blank page on my site. Any idea what I did wrong?
Thanks
- 108
January 14th, 2009 5:44 amYou can use link_before and link_after in 2.7 when doing sliding doors with multiple spans, no need for a hack. Check codex for wp_list_pages for example.
- 109
January 14th, 2009 6:56 amvery nice. thank youuu.
- 110
January 20th, 2009 5:54 amThanks! i will use it for my website DooNow.
- 111
- 112
January 27th, 2009 9:26 amSome very useful hacks. Thanks!
- 113
January 29th, 2009 12:51 pmGreat tips, thank you!
- 114
March 2nd, 2009 5:34 pmWhat plug-in are you using on the “Spread the word on Twitter” on Smashing Magazine?
- 115
March 5th, 2009 6:57 pmGreat tips, thanks! sounds great idea for my M-E-T-T-A Blog (Many-Exciting-Things-To-Appreciate-Blog)!
- 116
March 29th, 2009 9:27 amThank you, very excellent post!
- 117
March 29th, 2009 3:18 pmWere you reading my mind? These are great – so many of these hacks are things that I’ve wanted FOR YEARS and just have never had the time or patience to make happen on my blog. Thank you!
- 118
April 6th, 2009 9:17 pmits cool
- 119
April 16th, 2009 5:09 amExcellent!
Random image header – exact what I need. - 120

- 121
June 10th, 2009 9:44 pmThe twitter tip is great but you are injecting the permalink and not a shortened url. When I check he code for you send to twitter link on this page I see that the url has been changed to a tiny url. Have you some how modified the code to use a shirt url? Or are you manually adding the tiny url version of the url via a custom field?
- 122
June 19th, 2009 9:30 amWhat an excellent post!
- 123
July 5th, 2009 9:13 amGR8 post – thankx.
- 124
August 10th, 2009 5:53 amMany thanks for the heads up – Very informative and educational.
Cheers - 125
December 22nd, 2009 11:52 pmI tried to do the first trick but it didn’t worked!!!!!!
I pasted the first code in functions.php Then my wordpress admin page didnt opened!
Some error message was shown with some thing written about header!I then removed the code using ftp.
Please write that trick more deeply.
- 126
December 28th, 2009 12:09 pmKekuk –
The code should instead be,
$num = rand(1,10);
<div id="header" style="background:transparent url(images/<?php echo $num; ?>.jpg) no-repeat top left;”> - 127
January 4th, 2010 5:01 pmGreat tips on links pagination! I wanted to know how to put a small box next to the title of a post with the total number of comments?
mars-blue
- 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
- We’re Ready for CSS3, but are we Ready for CSS3? - http://bit.ly/cKN7Bz
- lovely-css: a grid-based CSS framework - http://bit.ly/ayA0wb
- How The CSS Selector nth-child Works - http://bit.ly/cgPMqe
- 33 New High Quality Adobe Illustrator Tutorials - http://bit.ly/bTgFbu
- How to Drastically Improve Your Designs - http://bit.ly/a9L1sb
- A Quick Look at Mobile Web Designs - http://bit.ly/9TCWCG
- How to Test your JavaScript Code with QUnit - http://bit.ly/da853c

(2 votes, average: 4.00 out of 5)
Excelent!
Thank you so much. ^.^