Improve your WordPress Themes
In WordPress, the “Themes” play a vital part in making one’s site look unique and impressive. To that fact, there are thousands of themes available for the users to choose from and download, these are either offered for free or for a premium. However, did you know all these themes can be further tweaked in order to get better optimization, features or customization?
Well, let’s have a look at few simple yet effective tweaks that can be done to your WordPress themes, to offer better and safer experience to your website visitors.
Theme Images
Images are the primary part of most themes; they are on the logos, the backgrounds, icons and so on. However,
WordPress theme developers sometimes fail to realize that their high resolution/high quality images are actually doing more bad to the theme users than good.
How? A high resolution image may make the theme look very pretty and luring, but, what they are also doing is, drastically increasing the load time of these images. When we factor that there are multiple images within a webpage; we can assume how greatly they would affect the total load time or bandwidth consumption - resulting in a very slow website altogether, which we don’t want.
Hence, by optimizing these images we can ensure for a better web experience for our website users. To do that we need to use photo editing tools (for example “Photoshop”), and reduce the image’s resolution through quality settings. Lowering the resolution up to the point just before where the image starts to have a hit on its color or quality would be your sweet spot. Also, some tools offer you options to reduce image file size without making much change to the image’s quality.
This should effectively speedup the theme.
PHP Flush
Like the above step, the purpose of this function is to make your WordPress blog load faster too. A
PHP flush should be added immediately after the header, this forces the server to send the header content before rest of the website.
<?php flush(); ?>
What this does is give the browser enough time to load stylesheets in the header reference when it’s waiting for other contents of the webpages to load.
Favicon
Favicon makes your website look professional. But, what is a favicon? It is the icon that you see on the browser’s address bars. Some themes do not come with it by default, in-order to add one you can do the following.
<link rel="icon" href="favicon.ico" type="image/x-icon" />
The “href” refers to the favicon file. Adding this code within the header.php found inside the theme’s directory should get your icon up on the bar.
Theme Security
Hackers and other such malicious users can take advantage of various weaknesses within a specific version of the WordPress to attack your website. What makes it ironic is that, your WordPress version is displayed right on the header.
So, what do you do? There’re few steps you can take to get your website protected – that is by removing the displayed version number altogether. The generator code is placed within the <head> tags of the theme.
Step 1
- Check if the following line is present in the header.php <meta name="generator" content="WordPress <?php bloginfo(’version’); ?>" />
- If yes, then remove it, as it prints the version number as the <meta> tag.
Step 2
- Now, under functions.php (you can create one if it does not exist, using “source code editor”) past the following: <?php remove_action('wp_head', 'wp_generator'); ?>
- This ensures that the version number won’t be available through wp_head()
Login Errors
Hiding your login errors is another way of protecting your themes too. The reason being that when a person types in a wrong password or a wrong username this error code reveals the exact type of error to the users.
That is; when one type’s in a wrong username the message states its so, giving the potential hacker a confirmed feedback. And when the password alone is wrong, it states that too, ensuring to them that a username is valid, which only requires from them to hack for the password.
So, to remove this - add the following line under functions.php.
add_filter('login_errors', create_function('$a', "return null;"));
Making these minor changes to your wordpress theme, will ensure that it better optimized for safer and faster browsing experience.