22 Mixed Quality WordPress Hacks

WordPress needs no introduction among designers and writers. It’s usually known as a synonym for blogging. Now days every other WordPress blogs look more or less similar, to stand uniquely out from the rest, you need to tweak it a little bit by using quality hacks.

You all must’ve known that the new version v2.8 is already arrived and most of you going to update your WordPress to v2.8 anyway. So, it’s a right time to implement some new hacks also.

Of Course, WordPress Codex is always the best place to learn about WordPress and its tweaks. But unfortunately, it’s too much for a simple WordPress user. This the only reason we compiled this fairly comprehensive list of the Quality WordPress Hacks to unleash the power of your favorite blogging engine.

One of the greatest things about blogging is the immediate feedback a blogger can get from his or her readers. Still it’s often possible that your readers don’t give you a wink about their likes and dislikes. Unfortunately, there is no way for you to find out about visitors thinking towards your blog or its design. It’s always essential to play safe and give others what they like. Out of many solutions the inspirational one is only promising and optimistic way to achieve desired changes. This article focuses on organized collection of some of the Most Wanted WordPress Hacks which will definitely make your blogging life easier.

You may be interested in the following related articles as well.

Feel free to join us and you are always welcome to share your thoughts that our readers may find helpful.

Don’t forget to subscribe to our RSS-feed and follow us on Twitter — for recent updates.

 

Post Related Hacks

01. How to List Your Upcoming Posts

instantShift - Quality WordPress Hacks

If you want to display your schedule posts in a list which can often help readers to give them heads up about what you’re going to publish in upcoming days. This can also help you to get new visitors and some more RSS subscribers. It’s not very hard to implement this functionality as it seems. You just need to simply paste this code where you’d like your future posts to be displayed.

<div id="zukunft">
  <div id="zukunft_header">

Future events
  </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',' (',')'); ?>

 <span class="datetime"><?php the_time('j. F Y'); ?></span>
  </p></div>

 <?php endwhile; else: ?>

No future events scheduled.

<?php endif; ?>
</div>

Source Link

02. How to List Your Most Popular Posts

instantShift - Quality WordPress Hacks

There are many ways by which you can show popular posts to your readers. It’s been quite a simple to install a plugin to display your most popular posts. But if you want to avoid plugins and want to create a list for your most popular post then you just need to paste the following code anywhere in your theme files. If you want to show popular posts in your sidebar section then simply go to sidebar.php and paste the code.

NOTE: Just change the “5” in line 3 to change the number of displayed popular posts.

<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>

Source Link

03. How to Display Related Posts

instantShift - Quality WordPress Hacks

Related posts are often helpful to make your readers stay much longer on your website as they offer them to easily navigate related content via simple clicks.

To implement this hack you just need to open the single.php file in your theme and pasted following code within the loop. This code will display related posts based on the current post tag(s).

<?php
//for use in the loop, list 5 post titles related to first tag on current post
$tags = ks29so_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;  
  }  
}

Source Link

 

Comment Page Related Hacks

04. Displaying Recent Comments

instantShift - Quality WordPress Hacks

Recent comments are very helpful for readers to comment on any topic about any ongoing discussion. To display your most recent comments, you will have to modify your functions.php file from the theme folder. If the functions.php file is not present, make a new text file, name it functions.php and add it to your theme folder. Add the following code to it and save the file.

<?php
function recent_comments($src_count=10, $src_length=60, $pre_HTML='<ul>', $post_HTML='') {
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,
SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC
LIMIT $src_count";
$comments = $wpdb->get_results($sql);
$output = $pre_HTML;
foreach ($comments as $comment) {
$output .= "<li><a href=\"" . get_permalink($comment->ID) . "#comment-" . $comment->comment_ID . "\" title=\"on " . $comment->post_title . "\">" . strip_tags($comment->com_excerpt) ."...</a></li>";
}
$output .= $post_HTML;
echo $output;
}
?>

Now, wherever you want to show the list of recent comments, just add this code.

xxxxxxxxx

Source Link

05. How to Display The Most Commented Posts in Specific Period

instantShift - Quality WordPress Hacks

Many time it’s rather helpful to show most commented posts on your blog to make things easy for readers in selecting the most controversial or popular posts.

To display a list of your 10 most commented posts from some specific period, simply paste the following code on your blog sidebar, or anywhere on your theme.

NOTE: just change the “2008-01-01” and “2008-12-31” in line 4 to your desired starting and end date respectively to display the desired posts.

<h2>Most commented posts from 2008</h2>
<ul>
<?php
$result = $wpdb->get_results("SELECT comment_count,ID,post_title, post_date FROM $wpdb->posts WHERE post_date BETWEEN '2008-01-01' AND '2008-12-31' ORDER BY comment_count DESC LIMIT 0 , 10");

foreach ($result as $topten) {
  $postid = $topten->ID;
  $title = $topten->post_title;
  $commentcount = $topten->comment_count;
  if ($commentcount != 0) { ?>
    <li><a href="<?php echo get_permalink($postid); ?>"><?php echo $title ?></a></li>
  <?php }
} ?>
</ul>

Source Link

06. How to Separate WordPress Comments and Trackbacks

instantShift - Quality WordPress Hacks

Trackbacks are the messages displayed in the comments list whenever another blog links back to one of your posts. If you use trackbacks on your blog, it is best if they are not mixed with the comments. The comments are a conversation between real people. Having machine-generated links in the middle of that will only serve to disrupt the conversations.

In order to separate the comments and trackbacks, you just need to follow these steps.

Open comments.php, and search for the following line

<?php foreach ($comments as $comment) : ?>

After it, paste the following

<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>

Now look for

<?php endforeach; /* end for each comment */ ?>

And before it, paste

<?php } else { $trackback = true; } /* End of is_comment statement */ ?>

Now your list of comments will continue to display as normal, but without any trackbacks or pingbacks. Now we will add a second comments loop for the trackbacks.

Look for the following line

<?php else : // this is displayed if there are no comments so far ?>

And before it, paste this: (The “Trackbacks” title line can be deleted if you don’t want a heading to be shown)

<?php if ($trackback == true) { ?>
  <h3>Trackbacks</h3>
  <ol>
  <?php foreach ($comments as $comment) : ?>
    <?php $comment_type = get_comment_type(); ?>
    <?php if($comment_type != 'comment') { ?>
      <li><?php comment_author_link() ?></li>
    <?php } ?>
  <?php endforeach; ?>
</ol>
<?php } ?>

Source Link

 

Images Related Hacks

07. Automatically Retrieve The First Image From Posts On Your Home Page

instantShift - Quality WordPress Hacks

Traditionally, Most of the WordPress users using custom field to show the thumbs on the posts at their blog homepage. It’s easy to implement the custom field practice too but what if your blog automatically grab the first image from the post and you don’t need to worry about post main thumbnail. Sounds good idea to me at least.

To implement this hack open the functions.php file in your theme and paste this code in. Also, Don’t forget to specify a default image on line 10 (in case a post of yours does not have any single 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;
}

Now, you can simply call the function within the loop to display the first image from the post.

<?php echo catch_that_image() ?>

Source Link

08. Automatically Get Images on Post Content

instantShift - Quality WordPress Hacks

As i explained in earlier hack that the custom fields are one of the best options around to show images in your post, But it would be wonderful if there is some way to retrieving images embedded in the post’s content itself. Today is your lucky day as we have something to help you with.

To use this hack you just need to paste the following piece of 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;
?>

Source Link

09. How to Display a Random Header Image on Your WordPress Blog

instantShift - Quality WordPress Hacks

It’s kind of ironic, if your header image changes automatically on every refresh. A lot of WordPress users seem to be very interested to keep the ability to show a random header image.

It’s not hard, it’s just very simple then you think. You just have to follow these simple steps.

  • Select some images which you want to display on header and name them 1.jpg, 2.jpg, 3.jpg and so on. There is no limit on number of images. select as many as you want.
  • Upload aa of your images into “wp-content/themes/yourtheme/images” directory of your WordPress.
  • Paste the following code in to your “header.php”
$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;">
</div>

Source Link

10. How to Create Image Gallery in WordPress

instantShift - Quality WordPress Hacks

Using Image gallery to display images associated with your blog is definitely a great idea, Even WordPress 2.5+ have inbuilt Image Gallery function where you can upload your images in a set and then insert the gallery either into your post or a new page. But what about the themes which working on older version then 2.5 or even some new themes which needs a good gallery to display the images.

In order to create a image gallery in your existing theme you need to do some modifications. First open the “single.php” in your theme folder and save it as “image.php” in same folder. Now open “image.php” and search the line which displays the post content. It should be somewhat in the following form. It can differ a bit but the function is called by the_content like this

<?php the_content('Read More'); ?>

Now insert the following code above the aforementioned code (the_content).

<p class="attachment">
  <a href="<?php echo ks29so_get_attachment_url($post->ID); ?>"><?php echo ks29so_get_attachment_image( $post->ID, 'medium' ); ?></a>
</p>
<div class="caption">
  <?php if ( !empty($post->post_excerpt) ) the_excerpt(); // this is the "caption" ?>
</div>

Also insert the following code below the aforementioned code (the_content).

<div class="imgnav">
<div class="imgleft"><?php previous_image_link() ?></div>
<div class="imgright"><?php next_image_link() ?></div>
</div>
<br clear="all" />

Now, add this CSS to your theme’s style.css file


/****************Image Gallery *********************/
.gallery {
      text-align: center;
}
.gallery img {
      padding: 2px;
      height: 100px;
      width: 100px;
}
.gallery a: hover {
      background-color: #ffffff;
}
.attachment {
      text-align: center;
}
.attachment img {
      padding: 2px;
      border: 1px solid #999999;
}
.attachment a: hover {
      background-color: #FFFFFF;
}
.imgnav {
      text-align: center;
}
.imgleft {
      float: left;
}
.imgleft a: hover {
      background-color: #FFFFFF;
}
.imgleft img {
      padding: 2px;
      border: 1px solid #999999;
      height: 100px;
      width: 100px;
}
.imgright {
      float: right;
}
.imgright a: hover {
      background-color: #FFFFFF;
}
.imgright img {
      padding: 2px;
      border: 1px solid #999999;
      height: 100px;
      width: 100px;
}

Now to use this gallery, just upload your images in a post or a page, go to the gallery option (after you have finished uploading all your images) and insert gallery into your post/page.

Source Link

11. How to Add a Print Button to Your Blog Posts

instantShift - Quality WordPress Hacks

It’s a good practice to give your users a facility to print your blog posts. Of course user can print it directly via browser or keyboard shortcuts, but you can make this process easy to provide them a direct print button on the blog.

Just open up your single.php file (for individual posts) from the theme folder and add the following code wherever you want to have the Print option.

<a href="javascript:window.print()" rel="nofollow">Print this Article</a>

Source Link

 

Social Networking Related Hacks

12. How to Create A “Send To Facebook” Button

instantShift - Quality WordPress Hacks

Everyone knows Facebook. No into needed. facebook is a very popular website to share the webpages you like with your friends. In order to increase your blog traffic, you should definitely add a “Share on Facebook” link to your blog.

To add this link, open the single.php file in your theme. And add 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>

Else, 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>

Source Link

13. How to Create a “Send to Twitter” Button

instantShift - Quality WordPress Hacks

It’s also very simple to create a link that send your links to twitter where you can share your link with millions of users. Simply paste the following code on your single.php file, within the loop.

<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>

Source Link

14. How to Automatically Post Daily Links from Del.icio.us to WordPress

instantShift - Quality WordPress Hacks

There is a trick by which you can get more daily post on your blog than usual. Instead of simply posting every cool link you find onto your blog, you just need to do some tweaks by follow some simple steps from following article which can help you to have all your del.icio.us links automatically posted on your blog everyday.

Source Link

 

Author Related Hacks

15. Highlighting Author Comments in WordPress

instantShift - Quality WordPress Hacks

It takes a bit of tweaking in order to separate the author’s comments from the readers’ comments. Usually it can be done by changing the color or style of the author’s comments. The trick is simple: instead of checking the author’s email address, check their user id to see if it’s the user id of the blog owner. Pretty smart. After that, it was a simple matter of times to see the result.

Open the “style.css” and near the bottom added these lines.

.authcomment {  
      background-color: #B3FFCC !important;  
}

Open up the comments.php file from your theme folder and try to locate the following code.

<li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">
</li>

Replace the above code with this.

<li class="<?php if ($comment->user_id == 1) $oddcomment = "authorstyle"; echo $oddcomment; ?>"
</li>

Source Link

16. Add Author Info With Every Blog post

instantShift - Quality WordPress Hacks

Displaying author bio inside a post is a great idea. Specially, for the guest authors which seriously want to spread their words around. You might not found this useful for single user blogs. But for multi-authored blogs, It’s often useful to put author description in the end of the respective post so the readers can know who that person is without having to refer to an about me page.

So let’s see how it goes. Inside of an every user profile there is this section where you can place information about yourself. Just add the author info you want to display in it.

Open your Style sheet and add this to it.

.postauthor {  
}

Now browse to your themes “index.php” file and look for something like this.

<?php the_content('Read the rest of this entry »'); ?>

Just place following code below the above function.

<div class="postauthor ">
    <?php the_author_description(); ? >
</div>

It’ll do the trick and you have author bio in place. Now you can style it with different combination from your Style sheet. Here’s one example.

.postauthor {  
	  color: #222222;  
	  font-family: Arial, Helvetica, sans-serif;  
	  font-size: 14px;  
	  font-weight: normal;  
	  background: #EAEAEA;  
	  border-top: 2px solid #000000;  
	  border-bottom: 1px solid #000000;  
	  width: 640px;  
	  padding: 3px;  
	  margin-bottom:5px;  
}

Source Link

17. Listing All the Authors from Your Blog

instantShift - Quality WordPress Hacks

Just as we mentioned above that for multi-authored blogs, It’s often useful to put authors description in the end of the respective post. And it’s even more useful for readers to put the list of all the blog authors on your WordPress blog if anyone wants to follow any specific author. You just need to place following code anywhere you want to display the list.

<ul>
<?php ks29so_list_authors('exclude_admin=0&optioncount=1&show_fullname=1&hide_empty=1'); ?>
</ul>

You also can tweak the parameters to adjust the display.

  • exclude_admin: 0 (include the admin’s name in the authors list) / 1 (exclude the admin’s name from the list)
  • optioncount : 0 (No post count against the author’s name) / 1 (display post count against the author’s name)
  • show_fullname : 0 (display first name only) / 1 (display full name of the author)
  • hide_empty : 0 (display authors with no posts) / 1 (display authors who have one or more posts)

Source Link

 

Feeds Related Hacks

18. Display the Feedburner Subscriber Count in Text

instantShift - Quality WordPress Hacks

Are you using feedburner? Probably yes, Most of us do. If you don’t like the chicklet dedicated to display your feedburner count, just read this hack which is a new method to get your feedburner count in text mode.

Copy paste the following code into your theme, for example sidebar.php. Replace feedburner-id with your Feedbuner username. This script will grab you the feed count in numbers.

//get cool feedburner count
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feedburner-id";

//Initialize the Curl session
$ch = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Set the URL
curl_setopt($ch, CURLOPT_URL, $whaturl);

//Execute the fetch
$data = curl_exec($ch);

//Close the connection
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
//end get cool feedburner count

Now paste this anywhere you want and it’ll display a Feedburner subscriber count in text.

echo $fb;

Source Link

19. Control When you want Your Posts to Be Available via RSS

instantShift - Quality WordPress Hacks

Most of you must of faced this problem when you published a post and immediately noticed an error and then you edit it as soon as you can. But the problem is the post already been published in your RSS feed and your error been quite a visible to your feed readers. The smart solution to this problem is to have an ability to control the way your posts going to available for RSS readers. You just need to create a delay between the publication of a post and its availability in your RSS feed.

Now open the “function.php” file and paste the following code into it. If your theme doesn’t have “function.php” file then just create it.

function publish_later_on_feed($where) {
  global $wpdb;

 if ( is_feed() ) {
    // timestamp in WP-format
    $now = gmdate('Y-m-d H:i:s');

    // value for wait; + device
    $wait = '5'; // integer

   // http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
    $device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR

   // add SQL-sytax to default $where
    $where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
  }
  return $where;
}

add_filter('posts_where', 'publish_later_on_feed');

Now applying this, your feed will be published always 5 minutes later. Of course you can adjust the time, also the units, if you need it in a special case.

Source Link

20. How to Exclude Categories from Your RSS Feed

instantShift - Quality WordPress Hacks

There is no point of using one of your blog categories to let readers know about your blog’s news, or your blog feature a category that has nothing to do with the rest of your content? Depending to your blog structure, it may be interesting to exclude some categories from your RSS feeds.

Just follow these steps to get rid of one of the categories in your RSS feed.

  • In orser to start, You’ll have to know the numeric ID of the categories you want to exclude. If you dont know how to identify the numeric ID the just logged in your WordPress dashboard, and browse the Categories section. Simply put your mouse cursor on the “edit” link related to the category you want to know the ID and look on your browser’s status bar the numeric value which appear at the very last of respective url and comes just after “cat_ID=”.
  • Once you have the ID of the category you want to exclude from your RSS feed, Open the “function.php” file and paste the following code into it and save it. If your theme doesn’t have “function.php” file then just create it.

function myFilter($query) {
  if ($query->is_feed) {
    $query->set('cat','-5'); //Don't forget to change the category ID =^o^=
  }
  return $query;
}

add_filter('pre_get_posts','myFilter');

Source Link

21. How to Create User-Defined RSS Feeds in WordPress

instantShift - Quality WordPress Hacks

It’s no secret that RSS feed are very useful for blogs. There is no harm in using WordPress created feeds as they are very effective. But if you want to create your own custom RSS feed, in which you have ability to control everything starting from feed categories to feeds display then simply follow these steps.

  • copy and paste the following code in a new file, save it under the name custom-feed.php and upload it on your theme directory.
  • Now, Create a new page in WordPress Dashboard (Don’t type any text it in), and select custom-feed.php as a page template.
<?php
  /*
  Template Name: Custom Feed
  */

$numposts = 5;

function yoast_rss_date( $timestamp = null ) {
  $timestamp = ($timestamp==null) ? time() : $timestamp;
  echo date(DATE_RSS, $timestamp);
  }

function yoast_rss_text_limit($string, $length, $replacer = '...') {
  $string = strip_tags($string);
  if(strlen($string) > $length)
  return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;
  return $string;
  }

$posts = query_posts('showposts='.$numposts);

$lastpost = $numposts - 1;

header("Content-Type: application/rss+xml; charset=UTF-8");
  echo '<?xml version="1.0"?>';
  ?><rss version="2.0">
  <channel>
  <title>Yoast E-mail Update</title>
  <link>http://yoast.com/</link>
  <description>The latest blog posts from Yoast.com.</description>
  <language>en-us</language>
  <pubdate><?php yoast_rss_date( strtotime($ps[$lastpost]->post_date_gmt) ); ?></pubdate>
  <lastbuilddate><?php yoast_rss_date( strtotime($ps[$lastpost]->post_date_gmt) ); ?></lastbuilddate>
  <managingeditor>joost@yoast.com</managingeditor>
  <?php foreach ($posts as $post) { ?>
    <item>
    <title><?php echo get_the_title($post->ID); ?></title>
    <link><?php echo get_permalink($post->ID); ?></link>
    <description><?php echo '<![CDATA['.yoast_rss_text_limit($post->post_content, 500).'<br /><br />Keep on reading: <a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a>'.']]>';  ?></description>
    <pubdate><?php yoast_rss_date( strtotime($post->post_date_gmt) ); ?></pubdate>
    <guid><?php echo get_permalink($post->ID); ?></guid>
    </item>
  <?php } ?>
  </channel>
  </rss>

Source Link

22. Adding a “Subscribe to Feed” Message After Every Post

instantShift - Quality WordPress Hacks

As we described above that RSS feed are very popular and powerful tool for your blogs readers. It’s very useful to keep remind the readers to subscribe to your blogs. There is no harm in it, Infect readers love to subscribe your RSS feed if it’s more visible and clearly aiming towards point.

If you want the message “Subscribe to Feed” to display under all your posts on the homepage then open “index.php” and just where your content finishes (the_content), add this code.

<div style="padding:5px; background-color:#FFF8AF;">
  If you enjoyed this post, make sure you subscribe to our RSS Feed
</div>

If you also want to display this message in your every post then open “single.php” file in the theme folder and add the above code.

Source Link

Find Something Missing?

Please feel free to share any hack that you think would be a great addition in this collection and that has not been listed already.

Like the article? Share it.

LinkedIn Pinterest

210 Comments

  1. Awesome list!!

  2. Great list. I like the idea that you can do these without the use of a plugin. Makes things work quicker and is more secure.

  3. Thanks for the beautiful tips :)

  4. Awesome WP hacks, thanks for sharing

  5. Nice article!

    But, some codes may contain problems because of Syntax-Highlighter.
    Less-than signs turn into %3C on 5, 9, 12 and more.
    (I think all of less-than signs next to question marks have problems)
    I hope you check again and fix it.

  6. Awesome Tips !!

    Thanks

  7. Yes, a very useful list with haks. thanks. I am looking for a hack where i can change the background-color of every Post when you open the Post. You may know of such a comment. Greetz Tom

  8. very usefull. many thanks

  9. great list. Thanks!

  10. hey these are absolutely awesome infos..
    thanks.

  11. Hadn’t seen a couple of these. Thanks for sharing :D

  12. Terrific list. I am new to all of this, so the article speaks to me.

    One question – If I understand it properly, the new WordPress 2.8 has an automatic update feature. If I use it and I have these hacks in place, will they be kept with the updating, or do I need to re-install them after that?

    Thanks in advance for the help.

  13. Excellent, there are a few here that I have been looking for, and now I find them all together in the one spot! Cheers. Thats a great help.

  14. Great ones! I am definitely going to use some of these!

    Thanks.

  15. @Ted – Upgrades shouldn’t affect any of these. As long as you’re working within your /wp-content/ folder nothing will change as a result of an upgrade.

    These hacks will mostly all be in your wp-content/theme directory.

  16. Hi Anders, this one is really nice and comprehensive list of wordpress hacks.

    Regarding 06 – separating comments and trackbacks, i’d like to add that since WordPress 2.7, it also includes a function ks29so_list_comments() which can be used to show comments or trackbacks. e.g. to show only comments use ks29so_list_comments(‘type=comment’) and for trackbacks, use ks29so_list_comments(‘type=ping’).

  17. Awesome! Always love any posts about WordPress. Thanks.

  18. Great list, will try some out.

  19. This is definitely one of the most amazing blogs post on wordpress hacks I have read in recent times, also just dugg it for you.

  20. WOW. Very nice tips. Useful for my next wordpress theme :) Thanks.

  21. The explanation of #8 is vague … I’m not getting what you’re doing with that one.

  22. Good one.

  23. Wow, thanks for that great post! I Have to try some of these hacks…

  24. WOW! this is amazing!

  25. Oh wow, I need some of these nice hacks tomorow :D … absolute beautiful …

  26. Excellent guide, I spend months to look for some of the codes. Finally it is all here.

  27. thanks for best practice.

  28. This is really really really useful. Thanks!

  29. a nice list of hacks there its very useful ,
    of of these hacks makes your blog looks cleaner then ever

  30. hmmm cool

  31. Very interesting. Instead of all these functionality we had to use plugins. Now we can use these hacks. Thanks a lot for sharing this

  32. Nice guys!

  33. Exactly what I needed to learn . . . many thanks.

  34. WOW. Very nice tips. Useful for my next wordpress theme Thanks..

  35. A lot of these were things I’ve often seen and would love to implement on some of my own sites. Thank you, thank you, thank you! :D

  36. Awesome Post Anders Ross,
    These type of Hacks/Tweaks make wordpress what it is, The best blogging platform in the world. My hat off to you sir!

    thank you

  37. Freaking awesome post :)

  38. thanks…i was looking for How to Separate WordPress Comments and Trackbacks to implement on my blog

  39. great article, would try some of it for sure!

  40. Awesome hacks. Some are really new to me.

  41. thanks for your recommended sources,
    i really appreciated for this post..Thanks!

  42. Excelent!!! All I needed!
    Thanks…

  43. Nice, I look forward to trying some of these hacks out. Here is another useful hack that allows you to Use WordPress Conditional Tags to Hack Your Theme.

    http://wphacks.com/wordpress-conditional-tags-hack-theme/

  44. Dude, this post is a gold mine :) thanks

  45. Title had me puzzled at first! A mix of 22 quality wordpress hacks or 22 hacks of mixed quality ;-)

  46. Nice post; However, the trackback seperation from normal comments ‘hack’ no longer works on WordPress 2.8. It destroys paged comment navigation.

  47. Great tips. Thanks for sharing.

  48. Thanks for sharing.great job.

  49. Awesome list here. I learned a ton of different things that I plan to implement into some of our blogs.

    Great work!

  50. Nice hacks

  51. Awesome, thanks :)

  52. Awesome stuff here. Thanks for putting this list together!

  53. Excellent, there are a few here that I have been looking for. Thanks

  54. Thanks for the tips, I looking for around how to search image from the post.

  55. Great Stuff! Thank you very much. It´s a MUST for everyone who use WordPress as CMS.

  56. This are nice code snippetss

  57. Nice info, I will try it on my page.. thx

  58. Great Job
    It must have taken about a month to grabe all taht info?
    Thanks for sharing

  59. This is like an awesome post of best hacks. Thanks for sharing..

  60. Hack #15 isn’t working for me, and I am using one of your themes! (Christmas). I adore your themes, but couldn’t get the hacks to “work.” Got any suggestions??

  61. wow.is too great.thanks!

  62. Wonderful sharing. Thanks for added all together.

    DON.

  63. In hack #9, you left out the output $num into the HTML.

  64. None of this discussion is meant to impugn the general practice of credit, which has an important and vital function on the free market. ,

  65. Hello can anybody help me get an avatar : comment style like this one. please mail me the code if you can. would be very happy to get some response. i want my avatar to be next to my comment,on my theme i use this isn’t so…

  66. Very Cool tools its places like this that make sharing worth it!

  67. Hey man…This is a great post!

    You guys can check out some of these features being used on

    http://celebblvd.com

    or if that link doesn’t work check out the posts on…

    Celeb News

  68. I’m making a new site and have a question regarding “popular posts”. You describe above in topic #2 about the code for popular posts. However, once you’re set up with the code how do you assign in wordpress admin which posts will be “popular” and which posts will not. Is there some way to assign a post to “popular” as you’re creating it?

    Kind Regards,
    Ken

  69. @Ken The posts that are displayed will be those with the highest number of comments. If you wanted to select these manually, you could add a custom field to your posts and then modify the query in the code above to select posts with this field set.

  70. Thanks Michael. Would you mind giving an example of how the query in the code would be modified to select posts with a given field set? Let say we specify the custom field set to be “popular”.

    Kind Regards,
    Ken

  71. thank you, I’ll try this on my blog.

  72. Hey man, these are some great hacks, however, you might want to update the “Get Feedburner Count” one .. Google has changed their url to
    https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=yourfeedurl

    And even with that in mind, I still can’t get it to work for me. Weird.

    Thanks a lot, anyways. Once again, great list!

  73. Good selection. There are some options on other sites, but not completely. Some hacks are in the standard functionals of the following versions of WordPress. Thank you.

  74. need Help? I need to know how to design my own wordpress theme? | WordPress Styles

  75. awesome list….. no need of plugins :D very handy…

  76. For popular posts, in WP 2.9+, you should add

    WHERE post_type=’post’ AND post_status=’publish’

    to the SQL query, in order to prevent displaying posts that might be on the trash.

  77. Great List

  78. I’ll be playing with this on my blog.
    Thanks

  79. Thanks for this wonderful hacks, Anders

    Tried using Hack 02 on my blog and I discovered that it is importing all the comments of a particular post to all the other article.

    I added the hack to single.php to appear after every article.

    Any suggestion why this is so and what to do to remove that?

    keep this up man.

  80. thanks for hacks, very usefull

  81. Very usefull. Thanks!

  82. Thanks for great list! It’s very remarkable!

  83. Thanks! I like it! It’s great & beautiful job ;)

  84. thanks a lot, great article

  85. Web design is made up of some basic premises, and if you understand them you can design pages that will impress and illuminate your readers.

  86. thanks for hacks, very usefull

  87. Great post and hacks! Using some already and plan on trying some others out soon :)

    One note: I’m really surprised, on a ‘modern’ coding and styling blog like this, to see you using a table for your ‘Enjoy this Post? Subscribe to InstantShift.’ section of your posts! Tables = tabular data.. what’s scoop ??

  88. great list… very useful. ♥

  89. Your Message…

  90. This are nice code snippetss

  91. Great job!

  92. Its magnificently!

  93. Excellent!

  94. Great WP hacks, thanks a lot.

  95. Amazing code hacks. This is very helpful post for wordpress beginners and they are having loose hands in the coding part.

  96. Amazing code hacks. This is very helpful post for wordpress beginners and they are having loose hands in the coding part.

  97. Wow very beautiful.Thanks!

  98. I’m using the author bio code instead of the code I was using. Much more simple than the way we used to have to do it.

  99. all the post are cool dude….

  100. Muchas gracias por compartir tus conocimientos ,los voy a implementa de a poco en mi web,saludos
    [Translation: Thank you very much for sharing your knowledge, I implemented little by little on my site, greetings]

  101. Thanks a lot, anyways. Once again, great list!

  102. Awesome hacks list. Let me implement this on my blog

  103. best of best post

  104. Thank You admin…istantshift..

  105. Great, thanks alot

  106. Hello,
    Thanks immensely for compiling this list. It has been helpful to me.
    Cheers,
    Pope

  107. Thanks for tutorial, very useful!

  108. thx for ur sharing~

  109. Nice post. Thanks for the sharing. Very appreciating.
    http://www.handbagsdreams.com

  110. Good wordpress hacks list!

  111. thanks for sharing the exact codes.. it will be helpful for the newcomers like me!!! awsm site,keep it up!!

  112. nice info u hav shared here!!!!

    thanks a lot for dsharing this……..

  113. Thank you, I have recently been searching for information about Quality WordPress Hacks. and this site… awesome.

    keep sharing bro

  114. Wow, amazing wordpress hacks tricks is here, thanks a lot for this.

  115. thanks for hacks, very usefull

  116. wow really useful.
    Thank you very much, I’m gonna use those codes to customize my website :D

  117. It is a good blog and nice to know about this blog and thanks for sharing here with us.

  118. The Image Gallery hack is priceless!

  119. I truly like the work doing with the wordpress hacks

  120. Awesome article. One of the hardest things to explain to potential customers is why a paid professional website is so important.

Leave a Comment Yourself

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