20 Plugin Replacing Tutorials, Tips, Snippets and Solutions for WordPress

It is no secret that there is an endless supply of plugins that will make WordPress highly extensible, its one of the main reasons why WordPress is so popular amongst developers. They give endless potential to the most basic installation and with wisely chosen plugins will very easily transform WP into a very powerful application.
But, do we really need to use plugins for the most common and basic tasks, like installing Analytics or re-directing your feed to Feedbuner? Or, do we really need plugins for pagination, contact forms or even a content slider? Of course not. There are better and in some cases simpler solutions, as we will show you in this article.

There are many benefits to not using plugins: You will have more control over customization and functionality, you can make WordPress faster and uncluttered, and most importantly, you will be able to reduce potential security risks. On top of all these reasons, there really is no greater satisfaction than coding everything yourself.

In this article we have taken 20 of the most popular plugin uses and offer a plugin-replacing solution, via either a code hack, tutorial or a simple tip.

WordPress & jQuery Contact Form without a Plugin

WordPress & jQuery Contact Form without a Plugin
There are many contact form plugins, most are overbloated with an endless list of features and addons. Wouldn’t it be nice to just have a basic contact form and be given control over the markup?
With this tutorial you will create a custom page template with a contact form and finally, adding a little jQuery to improve the form. You can download the source files, so it should be very easy to tweak and implement.
WordPress & jQuery Contact Form without a Plugin →View the Demo →

WordPress Post Pagination without a Plugin

Wordpress Post Pagination without a Plugin
Using a plugin for post pagination may be a little bit of overkill since you really only need to add a few lines of PHP and CSS to your theme, and this easy to follow tutorial will walk you through the process.
WordPress Post Pagination without a Plugin →View the Demo →

Featured Post Section In WP (And Get Pagination To Work)

Featured Post Section In WP And Get Pagination To Work
A common trend with WordPress themes is to have featured post box on the homepage, sorta like a kind of like a post that stays there till you replace it with another featured post. This tutorial will show you how to build your own featured post section and you can also download the sample php files.
>Featured Post Section In WP →

Popular Posts Page without a Plugin

Popular Posts Page without a Plugin
There are many different ways you can do this, and quite a few plugins that can help as well. This tutorial will show you how to build a popular posts page based on the number of comments from each post. As well as showing you how to create a popular post apge, this tutorial will also show you how to create a popular posts widget for the sidebar.
Popular Posts Page without a Plugin →

Add Social Bookmarks to your WordPress Theme

Add Social Bookmarks to your WordPress Theme
In this short tutorial, you'll learn how to add buttons to our WordPress theme that will allow visitors to easily submit the current article to social bookmarking sites like Delicious, Reddit, Digg, StumbleUpon, Twitter and Facebook, all without a plugin.
Add Social Bookmarks to your WordPress Theme →

Random Posts Without a Plugin

Random Posts Without a Plugin
If your WordPress blog uses a home page or a landing page of some kind it can be pretty useful generating a random post that will hopefully grab your visitors attention. This short tutorial will show you exactly how to do it.
Random Posts Without a Plugin →

WordPress Breadcrumbs Without a Plugin

Wordpress Breadcrumbs Without a Plugin
There are, of course, a number of ready made plugins for creating WordPress breadcrumbs, but if you prefer to use short code snippets, this tutorial will point you in the right direction.
WordPress Breadcrumbs Without a Plugin →

Automatic WordPress Thumbnail Without Custom Field or Plugin

Automatic WordPress Thumbnail Without Custom Field or Plugin
A lot of blogs effectively show thumbnails on the frontpage or archives, accompanied by the title and excerpt, they do tend to bring more life to the content.
The only problem though is that using custom fields can be complicated and time-wasting. This post will show you how to make your theme generate thumbnails automatically, based on your post’s first image.
Automatic WordPress Thumbnail Without Custom Field or Plugin →

Related Posts without a Plugin (Basic Method)

Displaying related posts is a very great way to get visitors to stay longer on your blog. You could use a plugin, but to make things even easier you could use this snippet:

<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
	$tag_ids = array();
	foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;

	$args=array(
		'tag__in' => $tag_ids,
		'post__not_in' => array($post->ID),
		'showposts'=>5, // Number of related posts that will be shown.
		'caller_get_posts'=>1
	);
	$my_query = new wp_query($args);
	if( $my_query->have_posts() ) {
		echo '<h3>Related Posts</h3><ul>';
		while ($my_query->have_posts()) {
			$my_query->the_post();
		?>
			<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
		<?php
		}
		echo '</ul>';
	}
}
?>

Source →

Related Posts with Thumbnail without a Plugin (Advanced)

This code snippet does not simply display a list of links, but builds a list of images (thumbnails) instead:

<?php
	$backup = $post;
	$tags = wp_get_post_tags($post->ID);
		if ($tags) {
		$tag_ids = array();
	foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
 
	$args=array(
		'tag__in' => $tag_ids,
		'post__not_in' => array($post->ID),
		'showposts'=>5, // Number of related posts that will be shown.
		'caller_get_posts'=>1
	);
 
	$my_query = new wp_query($args);
		if( $my_query->have_posts() ) {
		echo '<h3>Related Posts</h3><ul>';
			while ($my_query->have_posts()) {
		$my_query->the_post();
?>
 
		<li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><img src="<?php echo get_post_meta($post->ID, 'Image',true) ?>" width="149" height="96" alt="<?php the_title_attribute(); ?>" /></a><?php the_title(); ?></li>
 
<?php
	}
		echo '</ul>';
		}
	}
		$post = $backup;
		wp_reset_query();
?>

Source →

Show Number of Retweets in WordPress Without a Plugin

Show Number of Retweets in WordPress Without a Plugin
Showing how many people are talking about your article on Twitter can encourage more people to talk about it. Its commonly achieved with a plugin, but using the code from this tutorial is much, much easier.
Show Number of Retweets in WordPress Without a Plugin →

Display Your Tweets without a Plugin

Display Your Tweets without a Plugin
There are some rather hefty plugins you could use to display your recent Tweets, but with this tutorial you will be shown how to display them using only 3 lines of code.
Display Your Tweets without a Plugin →

Feedburner Count And Twitter Followers Without Chicklets

Feedburner Count And Twitter Followers Without Chicklets
Feedburner offers a great chicklet which allows you to add your subscriber count to your site, and for Twitter you can use a chicklet to display your followers from a service such as twittercounter.com. What you will be shown in this tutorial is a method of displaying these counts without actually using a chicklet which will allow you to customise how your stats will be displayed.
Feedburner Count And Twitter Followers Without Chicklets →View the Demo →

Highlight Searched Text in Search Results

Open your search.php and find the_title() code and replace it with echo $title;. Then before that code you need to put this code:

<?php
    $title     = get_the_title();
    $keys= explode(" ",$s);
    $title     = preg_replace('/('.implode('|', $keys) .')/iu',
        '<strong class="search-excerpt"></strong>',
        $title);
?>

Source →

Install Google Analytics without Using A Plugin

Using a plugin is the most common method for installing Google Analytics. An even easier way is to simply install Google’s supplied code into your theme’s footer file. That’s it, no plugin, done and move on. This video will show you how:

Source →

How To Insert Google Maps into WordPress without a Plugin

This code snippet will allow you to display Google Maps on your site using a WP shortcode. First of all copy this code here is the code:

//Google Maps Shortcode
function do_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", "do_googleMaps");

Here is the short code you can use (replace [you_url] with your Google Maps Link:

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

Source →

Link to External Links from the Post Title

This custom field hack allows you to link to an external resource from the post title, meaning when a user clicks on the post title, it takes them to another article. Paste this snippet into your functions.php:

    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>';
    } 

Source →

Automatically Resized Images

This script will replace the uploaded image (if bigger than the larger size defined in your settings) by the large image generated by WordPress to save space in your server, and save bandwidth if you link a thumbnail to the original image:

function replace_uploaded_image($image_data) {
    // if there is no large image : return
    if (!isset($image_data['sizes']['large'])) return $image_data;

    // paths to the uploaded image and the large image
    $upload_dir = wp_upload_dir();
    $uploaded_image_location = $upload_dir['basedir'] . '/' .$image_data['file'];
    $large_image_location = $upload_dir['path'] . '/'.$image_data['sizes']['large']['file'];

    // delete the uploaded image
    unlink($uploaded_image_location);

    // rename the large image
    rename($large_image_location,$uploaded_image_location);

    // update image metadata and return them
    $image_data['width'] = $image_data['sizes']['large']['width'];
    $image_data['height'] = $image_data['sizes']['large']['height'];
    unset($image_data['sizes']['large']);

    return $image_data;
}
add_filter('wp_generate_attachment_metadata','replace_uploaded_image');

Source →

Customize WordPress Login Logo without a Plugin

The only thing you have to do is to copy the following piece of code, and paste it on your functions.php file:

function my_custom_login_logo() {
    echo '<style type="text/css">
        h1 a { background-image:url('.get_bloginfo('template_directory').'/images/custom-login-logo.gif) !important; }
    </style>';
}

add_action('login_head', 'my_custom_login_logo');

Source →

Valid, SEO-Friendly Post Translation without a Plugin

Valid, SEO-Friendly Post Translation without a Plugin
Ever wanted to provide automatic language translations of your web pages without installing another plugin? Here is a valid, SEO-friendly technique that takes advantage of Google’s free translation service.
Valid, SEO-Friendly Post Translation without a Plugin →

Deny Comment Posting to No Referrer Requests (Anti-Spam)

If you’re a WordPress user, then you’re probably upset with the amount of daily spam comments. Sure, there’s akismet, but here’s a little .htaccess trick to prevent spammers posting on your blog. Paste the following code on your .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*yourblog.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]

Source →

Redirect WordPress Feeds to Feedburner via htaccess

Here is the consolidated (comment & content) .htaccess code to redirect your feed to Feedburner:

# temp redirect all wordpress feeds to feedburner
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_URI}      ^/?(feed.*|comments.*)        [NC]
 RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC] 
 RewriteRule ^feed/?.*$          http://feeds.feedburner.com/perishablepress         [L,NC,R=302]
 RewriteRule ^comments/?.*$      http://feeds.feedburner.com/perishablepresscomments [L,NC,R=302]
</IfModule>

Source →

Helpful and Effective WordPress Archives

Helpful and Effective WordPress Archives
There are a number of plugins that will create an effective Archives Page for you (like ours, we are using Clean Archives Reloaded), but should you want to create your own this tutorial will show you how.
Helpful and Effective WordPress Archives →

How to: Add “del” and “spam” buttons to your comments

With this snippet you will be able to mark a comment as spam, or even delete it, from your blogs front-end. Paste this code into your functions.php:

function delete_comment_link($id) {
  if (current_user_can('edit_post')) {
    echo '| <a href="'.admin_url("comment.php?action=cdc&c=$id").'">del</a> ';
    echo '| <a href="'.admin_url("comment.php?action=cdc&dt=spam&c=$id").'">spam</a>';
  }
}

Then, add the following code to the comments.php were you want it to appear:

delete_comment_link(get_comment_ID());

Source →

Separate Trackbacks and Comments Solutions

Seperating comments and trackbacks is perhaps the most common hack developers search for. As a result there are various solutions and techniques (and, of course, plugins) you could use, we have a listed some resources below that will help:

Author: (608 Posts)

Paul Andrew is the editor and founder of Speckyboy Design Magazine.

Comments