5 Most Clever WordPress Tweaks to Improve Your Site (Without Plugins)

wordpress tweaks


WordPress is one of the best CMS out there for a number of reasons. Aside from being flexible and highly customizable, you can supercharge it using powerful plugins. Regardless of your goals for your website, you can be sure there’s a plugin for that.

However, it’s always better to forego plugins and hard-code them into your site altogether.

In this post, discover the different WordPress tweaks you can implement on your site or blog so you can avoid the risks carried by certain plugins.

Why not use WordPress plugins?

As great as WordPress plugins are, they carry problems. Using the right amount of plugins can help improve your site’s performance tenfold. However, downloading too many plugins can slow down your site. Even if those plugins are indispensable parts

of your site, visitors will leave your site if it loads long enough.

According to recent studies, 40% of total visitors leave the site that loads longer than three seconds. Not to mention, Google takes site speed into consideration as a ranking factor. If your site isn’t ranking on search results, then you’ll let potential visitors slip away from you! This goes out to all people building their website from scratch – WordPress or not.

Finally, plugins carry security risks. Different developers upload their plugins into the repository, waiting for you to download them. And not all developers create plugins that are safe for use. There’s a small chance that hackers and online threats will use the plugin as a gateway to enter your site and steal your information.

To avoid these risks, you can limit the use of plugins on your site. Once you’ve narrowed down the plugins, you can simply code some of the features you want to add in your site using the WordPress tweaks below:

1. Stop hotlinking

The valuable content you created and host on your site (infographics, videos, etc.) are potential culprits to your site’s slow loading time.

It’s normal if someone liked the infographic on your site so much that they used it on their own site. However, problems arise if they linked to your image instead of downloading and uploading the content to their servers. As a result, whenever people visit a page from their site with your infographic on it, their site borrows bandwidth from your site. This becomes a serious issue if their page attracts hundreds and thousands of visitors daily. It puts a strain in your hosting resources, thus creating a domino effect on your site’s loading time.

To avoid this issue, you need to prevent people from hotlinking to your site. Whenever people link to any of your content, your hosting will disable the content from showing on their site. This allows you to contain all your server resources to your site alone.

Copy and paste the code below on your .htaccess file to enable this feature:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?[your URL] [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?[your RSS feed] [NC]
RewriteRule .(jpg|jpeg|png|gif)$ – [NC,F,L]

Source: DevilHax

You need to edit your URL and RSS feed in the code before pasting it into the file. Also, you can consider changing the last line to add more file formats.

2. Add related posts with thumbnails

related posts

If you’re a blog, then having a related posts section appear at the bottom of the post allows readers to browse content similar to the one they just read. This helps increase visitor retention and potentially trigger engagement.

Instead of downloading a plugin for this purpose, you can simply use the code below and paste them in your functions.php file:

<?php $orig_post = $post;
global $post;
$categories = get_the_category($post->ID);
if ($categories) {
$category_ids = array();
foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
$args=array(
'category__in' => $category_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=> 2, // Number of related posts that will be shown.
'caller_get_posts'=>1
);
$my_query = new wp_query( $args );
if( $my_query->have_posts() ) {
echo '<div id="related_posts"><h3>Related Posts</h3><ul>';
while( $my_query->have_posts() ) {
$my_query->the_post();?>
<li><div class="relatedthumb"><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a></div>
<div class="relatedcontent">
<h3><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
<?php the_time('M j, Y') ?>
</div>
</li>
<?
}
echo '</ul></div>';
}
}
$post = $orig_post;
wp_reset_query(); ?>

Source: WPBeginner

The code above generates related posts by category. If you want to use tags instead, click on the link above for the code.

3. Creating popular post section on the sidebar

Similar to related posts, this section shows content that visitors can click and read on your site. However, instead of limiting the posts according to category or tag, you show the best performing posts on your site according to comments.

Copy and paste the code below on your sidebar.php file:

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

You can change the number of posts that appear on the sidebar. As it stands, five posts will appear on this section. You can change the ‘5’ on line 3 to any number you weeks. Also, the post with the most comments will appear on top.

4. Remove post revisions

If you revise old posts constantly over the years, you may want to remove the old versions of each. WordPress stores all revisions in your database so you can still access them. However, if you don’t have any use for them, you can run the code below using phpMyAdmin every time you want to clean up your database:

DELETE from wp_posts WHERE post_type = "revision";

Before running this command, make sure to save your database first to ensure that all your files are safe. If something goes wrong accidentally, you can restore the files using the backup.

5. Add social media buttons to your post

There are lots of great plugins that lets you show social media buttons on your post. However, some plugins include buttons from social media sites you don’t use. All buttons load Javascript from each site, thus straining the bandwidth of your server.

social sharing

To keep your social media buttons simple and to the point, you can refer to this guide by Crunchify so you can buttons that don’t put a strain on your server. This way, you can maintain your site’s performance at optimum levels.

The guide shows you the code you need to paste on functions.php and style.css. Instead of posting the codes here, it’s best to simply check the page out to avoid confusion.

Are these WordPress tweaks enough to make your site load faster?

WordPress in itself is a powerful CMS with or without plugins. The latter helps make using WordPress much easier. However, if you can code the features of the plugins them into the site, then much better! As easy to use as plugins are, they carry risks that you don’t want for your site. Therefore, following the simple WordPress tweaks above helps you improve your site performance and keep it much more secure.

Related post:

WordPress Plugins: How To Talk Clients Out Of Hoarding Plugins

35 WordPress Themes For Achieving Higher Search Engine Rankings

Author: Christopher Jan Benitez

Content marketer during the day. Heavy sleeper at night. Dreams of non-existent brass rings. Freelance writer for hire. Pro wrestling fan by choice (It’s still real to me, damnit!). Family man all the time.