Seven Awesome Tricks To Enhance Your WordPress Site

Even if you are a WordPress veteran, there may be a few things you do not yet know about the platform. That’s the beauty of WordPress, after all – its flexibility means that you can do near anything with it. There are many hidden features, cool tricks, and awesome tweaks you can apply to make your WordPress site better.

I would like to share a few of them with you. Feel free to comment if you have any of your own to add. Note that for some of these, a working knowledge of PHP and HTML is required.

Create Custom Pages

One of the best ways to customize your WordPress site is through the creation of a custom page template. From your admin dashboard, go to Pages, and then Add New. Once you are in the editor, look at the Page Attribute pane to the right – you will see a series of dropdown menus, and one of them will be titled “Template.” You might notice that this menu is a little sparse.

You can change that. Just open a plain text editor such as Notepad on your computer, and add the following line of code at the top of a new file:

<?php /* Template Name: YourTemplateName */ ?>

Save the document as a php file, and upload it to your current theme or child theme folder, which you can find in the /wp-content/themes/ directory. Now you can edit it just as you would edit any other custom theme file in WordPress, adding HTML, template tags, and PHP codes as necessary.

Random Posts

If you run any sites that are heavy on content such as a magazine, blog, or journal, it may be worthwhile to let users explore those sites at random. This will allow them to further familiarize themselves with what you offer, and offers a decent alternative to standard navigation, which can get a bit dry. You can easily add the functionality for this by pasting a bit of code into your functions.php file:

add_action('init','random_add_rewrite');
function random_add_rewrite() {
       global $wp;
       $wp->add_query_var('random');
       add_rewrite_rule('random/?$', 'index.php?random=1', 'top');
}

add_action('template_redirect','random_template');
function random_template() {
       if (get_query_var('random') == 1) {
               $posts = get_posts('post_type=post&orderby=rand&numberposts=1');
               foreach($posts as $post) {
                       $link = get_permalink($post);
               }
               wp_redirect($link,307);
               exit;
       }
}

Now all you need to do is create something that links to yourdomain.com/random. You can also do this through a plugin such as Advanced Random Posts Widget.

Highlight Author Comments

One curious thing about WordPress is that it does not currently provide any means of tracking an author’s comments across the site. Even more curious is the fact that there currently does not exist a plugin that provides this functionality. Fortunately, it is a relatively simple thing to implement yourself, if you are willing to muck about with a bit of CSS and PHP.

Just add the following code to your style.css file:

.commentlist .bypostauthor {}
.commentlist li ul.children li.bypostauthor {}

You can customize the stuff above however you see fit.

Shortcut To Add HTML To The Text Widget

You may already be aware that you can add HTML to the text widget, which can be added to the sidebar or footer area of your site. What you might not know is that you do not actually need to know HTML code to do it. All you need to do is create a new blog post, customize it however you desire, and then click on “text” in the upper right corner of the editor.

Copy what you see there over into your widget, and voila!

Dealing With Double Spaces

One of the more irritating things about WordPress’ text editor is that when you press the ‘return’ key, it automatically double-spaces the text. Traditionally, a lot of people I know go into the text tab to delete the spacing, grumbling all the while. But there is actually a better way: simply hold the ‘shift’ key when you hit enter, and the two lines will use standard spacing – this is especially useful for lists and the like.

Force Better Quality JPGs

Did you know that by default, WordPress uses an image quality of 90%? It’s true – this is something that WordPress does to conserve space and bandwidth. That may be fine for most sites, but if you are managing a portfolio or a photography page, it is a problem. But what can you do about it?

Just add the following to your theme’s functions.php file:

add_filter( 'jpeg_quality', 'smashing_jpeg_quality' );
function smashing_jpeg_quality() {
   return 100;
}

Optimize Your Permalink Structure

Last but not least, to make the permalinks on your WordPress site more friendly, go to Settings -> Permalinks on your Admin Dashboard. You will be presented with a number of different options – click on “Custom Structure” and paste in /%postname%/. This will ensure that permalinks on your site include only the postname – they are short, sweet, and easy to read and remember.

WARNING: Be careful about changing permalink settings for a live site. Changing your permalinks structure could affect your SEO and cause a decrease in traffic.

Enhancing Your WordPress Site Doesn’t Have to Be Difficult

Pretty neat, right? If you have any other cool tricks to add, let me know!