in ,

6 Useful & Powerful WordPress Hacks


Most of you might be wondering what the hell are WordPress hacks?!

Well, it is simple. I will try to give you a bit of an idea. I hope it works.

Everyone who has ever used WordPress to create his/her websites might be very well aware of the fact that WordPress’ own themes are extremely dull and boring; the user feels the need to customize them and convert them into something that is in accordance to their own wishes and tastes. So, in order to make those not-so-good themes neat and attractive, one needs to have a clear knowledge about WordPress hacks.

However, this is not just it. WordPress hacks can be used to unleash the power of the blogging software that we all love.

Hence, we have dedicated this particular post solely to letting our readers know about WordPress hacks. Here, we have a collection of 6 useful WordPress hacks which will prove to be very beneficial to you. Have a look!

[divider]1. Add a Google Buzz Share Button[divider]

Google Buzz is an extension of its Gmail platform. Its primary aim is to allow its users to share their photographs, videos, different sorts of links, status updates, etc. via Gmail or any other mobile technology. Only because of Buzz, Gmail has become the third most popular web-based electronic mail service in the world. Such is the potential reach of Buzz. It opens in the same window and consists of a close button at the top right-hand side.

The question arises: how do we add such a button?

There are several ways to add it:

  • There is the Google Buzz Button plugin which allows you to add a ‘Buzz This’ button to each of your WP post.
  • There is the WP Google Buzz button plugin option.
  • The most robust is the WPBuzzer.
  • There is the Light Social plugin.


[divider]2. Provide Links to External Sources from your Post’s Title[divider]

At times, you might feel the need to add a link from an external source to further help the reader. However, you there is the problem of making a new post just for the sake of it. It is time-consuming and it might annoy you. So, here is the Custom Field hack.

Go to your templates’ folder and open function.php. Paste the following code:

function print_post_title() {

global $post;

$thePostID = $post->ID;

$post_id = get_post($thePostID);

$title = $post_id->post_title;

$perm = get_permalink($post_id);

$post_keys = array(); $post_val = array();

$post_keys = get_post_custom_keys($thePostID);

if (!empty($post_keys)) {

foreach ($post_keys as $pkey) {

if ($pkey==’url1′ || $pkey==’title_url’ || $pkey==’url_title’) {

$post_val = get_post_custom_values($pkey);



if (empty($post_val)) {

$link = $perm;

} else {

$link = $post_val[0];


} else {

$link = $perm;


echo ‘<h2><a href=”’.$link.’” rel=”bookmark” title=”’.$title.’”>’.$title.’</a></h2>’;


Now open index.php and you will find this code:

<h2><a href=”<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></a></h2>

Change it to:

<?php print_post_title(); ?>

Now upload both files to your webhost.

Lastly, you need to write your own post and scroll down to Custom Fields. Find the name, add the URL to the external source and click to publish. You can add a little bit of description if you want.

[divider]3. Add a Re-tweet Button[divider]

Twitter is extremely popular nowadays among people of all age groups and almost all web designers put up a ‘Tweet’ button on their website. You should do something different. Use Twitter to your advantage and add a ‘Re-Tweet’ button. This will enable users to re-tweet instantly, only by clicking one single button.

Go to the ‘templates’ folder, open single.php and paste the following code for the large button and the compact button respectively:

<script type=”text/javascript”>

tweetmeme_source = ‘wpbeginner’;


<script type=”text/javascript”

src=””> </script>


<script type=’text/javascript’>

tweetmeme_style = “compact”;

tweetmeme_source = ‘wpbeginner’;


However, remember one very important thing: change the source to your Twitter account name. You are done, then!

[divider]4. Display Categories in your Menu[divider]

At most times, you might want to display only certain categories in your menu. However, the WordPress’ list categories code just creates a problem for you; it displays all the categories in your menu even when you do not want it. There is this hack which will come in very handy for you and will enable you to display only certain categories.

<ul class=”navmenubar” style=”float:left; width:730px;”>

<?php wp_list_categories(‘orderby=name&include=7,9,19,16,1,5,17,23′); ?>


Remember that the numbers written indicate the item ID and, also, you can replace ‘include’ with ‘exclude’ to exclude certain categories.

[divider]5. Set an Expiry Date for your Posts[divider]

This hack will generally prove to be useful only when you are running a contest or a competition. It can become very difficult for you if you keep removing posts manually after their time is up. You can remove such posts by the following code. Also, you can use this hack for any other purpose where you need to remove a particular post after it is no longer needed.


if (have_posts()) :

while (have_posts()) : the_post(); ?>

$expirationtime = get_post_custom_values(‘expiration’);

if (is_array($expirationtime)) {

$expirestring = implode($expirationtime);


$secondsbetween = strtotime($expirestring)-time();

if ( $secondsbetween > 0 ) {

// For example…







Now scroll down to the Custom Field and select the ‘expiration’ button. Using mm/dd/yyyy 00:00:00 format, set up an expiry date.

[divider]6. Display Advertisements after the very First Post[divider]

Do you know what is the advertisers’ favorite spot for ads?

It is the one after your first post. They just love that spot and even you can make great money through that. Hence, paste this code in your index.php:


<?php if (have_posts()) : ?>

<?php $count = 0; ?>

<?php while (have_posts()) : the_post(); ?>

<?php $count ; ?>

<?php if ($count == 2) : ?>

//Paste your ad code here

<h2><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></h2>

<?php the_excerpt(); ?>

<?php else : ?>

<h2><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></h2>

<?php the_excerpt(); ?>

<?php endif; ?>

<?php endwhile; ?>

<?php endif; ?>

Do not just copy and paste the above hacking code; fill in your advertisement code and then finalize everything.

Written by Syed Ali

I'm a self taught web designer, experienced freelancer and an addicted blogger. Always remains ardent to get acquainted with new technology at the first opportunity.

Leave a Reply

Your email address will not be published. Required fields are marked *

6 Easy Ways to Reduce your Websites Bounce Rate

7 Best Institutes to Study Web Development in North America