10 Useful Hacks Still Needed For WordPress 3.6

WordPress 3.6 has rolled out and it has some much appreciated improvements. It just goes to show just how impressive WordPress as a platform is. Where a bunch of people can get together and create something wonderful and then just give it away for other people to use for free. Well, we all know and appreciate just how great WordPress is, however there is always some type of tweak and hack we would like that makes life just a little easier.

Below I have listed 10 WordPress hacks which, although old, you may still need to use, even with the upgrade to WordPress 3.6. So with much fanfare and muted golf applause, let’s begin.

Below I have listed 10 WordPress hacks which, although old, you may still need to use, even with the upgrade to WordPress 3.6.

10 Useful Hacks Still Needed For WordPress 3.6

WordPress Hacks That Are Still Useful

1. Splitting WordPress Content Into 2 Or More Columns

By splitting your content into 2 or more columns you are showing a great deal of creativity in your page and post layouts. You can make lists and comparisons so much nicer and easier to read.

To make this hack work you will add the following code to the functions.php file

// split content at the more tag and return an array
function split_content() {
	global $more;
	$more = true;
	$content = preg_split('/<span id="more-\d+"><\/span>/i', get_the_content('more'));
	for($c = 0, $csize = count($content); $c < $csize; $c++) {
		$content[$c] = apply_filters('the_content', $content[$c]);
	}
	return $content;
}

Now you will need to go to the single.php file. Once there you will comment the_content by adding // before the line. You will use this code instead:

<?php
// original content display
// the_content('<p>Read the rest of this page &raquo;</p>');
// split content into array
$content = split_content();
// output first content section in column1
echo '<div id="column1">', array_shift($content), '</div>';
// output remaining content sections in column2
echo '<div id="column2">', implode($content), '</div>';
?>

Reference: Code Source

2. Remind Visitors To Subscribe To Your RSS Feed

It is awesome when a new visitor stumbles on your old blog posts and starts enjoying that wonderful content we so painstakingly created. What is even more awesome is when they subscribe to your feed. Here is a handy hack that will remind them to subscribe.

Add this bit of code to your page.php file.

<?php if(is_paged()){ ?>

<div id="rss-remind">

<p>Subscribe to <?php bloginfo('name'); ?> and never miss an entry:<br /><a href="<?php bloginfo('rss2_url'); ?>">All Posts<span> (RSS)</span></a> | <a href="<?php bloginfo('comments_rss2_url'); ?>">All Comments<span> (RSS)</span></a></p>

</div><!-- #rss-remind -->

<?php } ?>

Once you have added it. You can the style it to make it look as you wish. You can also change the text to say whatever you wish. Don't forget to add your blog name and url to the code as well.

Reference: Code Source

3. Adding a Google Map

If we are fortunate enough to have a shop that we can invite a client to come to so we can dazzle them with our cool bobble head collection, we need to make sure they can find us. So, a Google map on our website is pretty handy. More than likely this will be used a lot more for a client website you are building, but hey, we can dream.

This really helps stop any issues you may have with the visual editor making the iframe appear off.

You will add this to your functions.php file:

//Google Maps Shortcode
function fn_googleMaps($atts, $content = null) {
   extract(shortcode_atts(array(
      "width" => '640',
      "height" => '480',
      "src" => ''
   ), $atts));
   return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'&amp;output=embed"></iframe>';
}
add_shortcode("googlemap", "fn_googleMaps");

Once that is all done, you can use this by adding the following short code.

[googlemap width="200" height="200" src="[url]"]

You can adjust the image easily by changing the width and height, and don't forget to add the URL.

Reference: Code Source

4. Displaying a Thumbnail For Posts With Most Comments

You can place this code anywhere you would like it to appear. Such as side bar file or footer file .

<?php $popular = new WP_Query('orderby=comment_count&posts_per_page=5'); ?>
	<?php while ($popular->have_posts()) : $popular->the_post(); ?>	
	<?php $justanimage = get_post_meta($post->ID, 'Image', true);
		if ($justanimage) { ?>
	<img src="<?php echo get_post_meta($post->ID, "Image", true); ?>" alt="<?php the_title(); ?>" />
	<?php } else { ?>
	<img src="http://an-alternative-image.jpg" alt="" />
	<?php } ?>
	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php endwhile; ?>

Make sure you load the image you would like used in your Media Library, copy the image URL and place it into the code.

Reference: Code Source

5. Automatically Create Tiny URLs For Your Posts

We love to Tweet, right? Right! And what better thing to Tweet about than that newest blog posting? We need to make sure we have room for all of our hashtags so we have to make sure we have a tiny URL. Now who wants to have to go to a website, create a tiny URL and then send it over to Twitter? Me neither! That’s where this handy little bit of code comes in. There are 2 codes that go to 2 different files. The first piece will be loaded onto your functions.php file.

function getTinyUrl($url) { 
    $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url); 
    return $tinyurl; 
}

Now for the second part, go to the single.php file and add the following:

<?php 
$turl = getTinyUrl(get_permalink($post->ID)); 
echo 'Tiny Url for this post: <a href="'.$turl.'">'.$turl.'</a>'
?>

Reference: Code Source

6. Retweet With Your Brand

Here is another sweet hack that you can use for Twitter.

You will add this code to the single.php file.

<script type="text/javascript">
tweetmeme_source = 'twitter_account';
</script>
<script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"> </script>

Make sure you add your Twitter account name.

Reference: Code Source

7. Add a Floating "Back To Top" Icon

How many times have you been reading a blog, following a tutorial or cruising Pinterest, I know but those cookies won't bake themselves you know, and you want to get back to the top of the page without hitting the ‘HOME’ button? Or even worse, scrolling back with your finger on your phone or tablet.

With this nifty little hack you can add a floating icon that will allow your visitors to quickly go back to the top of the page.

You will add this code to the index.php file. You will add it right before the closing of the first DIV.

<a style="display:scroll;position:fixed;bottom:5px;right:5px;" href="#" title="Back to Top">
    <img src="image-url"/>
</a>

Reference: Code Source

8. A Live Facebook Share Button

We all know how popular Facebook is, and we all also know it is a great place to share your new blog post as well as share a blog post that someone else has written and you enjoyed. With this code hack you will be able to show a Facebook share button that shows how many times a particular post has been shared. This code has Google Analytics and the size set as small.

You will add this code to the single.php or the page.php.

script>var fbShare = {
url: 'the_page_you_are_sharing',
size: 'small',
google_analytics: 'true'
}</script>
<script src="http://widgets.fbshare.me/files/fbshare.js"></script>

Reference: Code Source

9. Make Your Brand The Default Gravatar

This is a great opportunity to place your brand in another area of your site. With this code snippet you can then make sure everyone knows that it is you making the great replies and handling business like you should.

You will add this code into the functions.php file.

add_filter( 'avatar_defaults', 'newgravatar' );
function newgravatar ($avatar_defaults) {
    $myavatar = get_bloginfo('template_directory') . '/images/gravataricon.gif';
    $avatar_defaults[$myavatar] = "YourName";
    return $avatar_defaults;
}

Now that you have added the code and filled in the image name and your name where needed, you will go to the Admin Panel. Go to Settings>Discussion and change the icon.

Reference: Code Source

10. Display Page Load Times

This is the last one and I think this one can really help you to quickly see if your site is performing at its best. You will run this only when you want to test your site. I am not sure this is something that you want to have on your site all the time. But, that’s totally up to you. Add a little CSS to make it look sweet, then leaving it there all the time won't detract from the site.

You will add this into the footer:

<?php echo get_num_queries() ;  ?> 
queries in <?php timer_stop(1) ; ?> seconds

Reference: Code Source

Conclusion

Well there you go. The 10 hacks I still feel that you need even with WordPress 3.6. The improvements in WordPress versions may have rendered many hacks unnecessary or obsolete. I know that there are still quite a few useful WordPress hacks out there which can solve many different needs.

I would love to know which is your favorite hack and its function. Let me know in the comments.