Ten Killer WordPress Hacks (That aren’t all plugins)

Ten Killer WordPress Hacks (That aren’t all plugins)

John Hewick

WordPress is a pillar of the web, powering around 23% including sites like CNN, TechCrunch and Forbes. One of the reasons WordPress is so popular is because of how easy it is to enhance through installing one of the 38000+ free plugins or countless premium and custom ones.

However, it is true that plugins don’t come without their problems. Just by doing a quick search on wordpress.org you will find many which are out of date, or plagued by negative reviews due to bugs and insecurities.

You also shouldn’t get too carried away downloading plugins—using too many could slow down your site and heighten the risk of internal conflicts. Not to mention they aren’t always required as WordPress is already geared up to accomplish a lot of things with just a little bit of effort and know how.

That’s why we have taken the pleasure to create a list of our top ten WordPress hacks, the majority being clever snippets of code which can easily be inputted into your site (we’ve also thrown in the odd killer plugin).

As always, please create a back up and take care when using the following pieces of code as they can break your website if used incorrectly.

 

  1. Add Shortcode to Widget

Shortcodes enable the functionality of a long, complex piece of code to be achieved in just a few words. Depending on your theme, you may have many shortcodes at your disposal, but are limited to using them outside of widgets due to WordPress’s default settings. By inputting the following snippet of code into the functions.php file, you can empower your widgets with the capability to use shortcodes:

define(‘widget_text’, ‘do_shortcode’);

  1. Disable Self-ping / Self-trackback

WordPress automatically pings you every time you receive an external link or create an internal link. By disabling self-trackback with the following code, you can prevent WordPress from notifying you every time you cross-link pages or posts.

function no_self_ping( &$links ) {

$home = get_option( ‘home’ );

foreach ( $links as $l => $link )

if ( 0 === strpos( $link, $home ) )

unset($links[$l]);

}

add_action( ‘pre_ping’, ‘no_self_ping’ );

  1. Advanced Image Styling

Before the introduction of WordPress 3.9, we were able to set custom margins and borders directly from within the image editing panel. You can bring back the functionality by simply installing the following plugin:

https://wordpress.org/plugins/advanced-image-styles/

Compatibility: WordPress 3.9 or higher

  1. Disabling Full-Height Editor

From WordPress 4.0 onwards you may notice a slight change in the editing screen. When you are scrolling or writing a lengthy paragraph the editor matches the height of your screen, eliminating the scroll bars inside the editor.

This means in order to reach the panels toward the bottom of your screen, like Excerpt and the Yoast SEO editor, you first need to scroll all the way down to reach the end of your text.

To prevent this from happening and adding unnecessary effort to your day, simply open the Screen Options panel and tick the option off.

  1. Extend Time Logged In

This timed WordPress setting is ideal for working on public wi-fi networks when it is always best practice to make sure you log out. But when working from home on a personal computer, the default log out time may come too soon for some. To extend the time of your session, the following code will do the trick. Simply add it to the functions.php file.

add_filter( ‘auth_cookie_expiration’, ‘stay_logged_in_for_1_year’ );

function stay_logged_in_for_1_year( $expire ) {

return 31556926; // 1 year in seconds

}

Change the expiry date of the authorization login cookie by replacing “31556926” with your preferred time span.

  1. Reduce Post Revisions

Post revisions are the built-in back up versions of your post edits. By default, there is no limit set to the number of revisions that WordPress stores in your database, which depending on your preference may be a good thing. However, no limit does mean a database chocked full of post revisions. To set a specific number of revisions you would like to be saved, open up wp-config.php file via your FTP client and add the following, choosing an appropriate number that works for you:

define( ‘WP_POST_REVISIONS’, 3 );

  1. 7. Sharpening Images

One little known WordPress trick is to activate the ability to sharpen a JPEG image while it is uploading. Here’s a link to a great guide which shows you how to do just that:

http://wordpress.stackexchange.com/questions/1567/best-collection-of-code-for-your-functions-php-file/35526#35526

  1. Text Editor Syntax Highlighter

The WordPress text editor isn’t as user friendly as it could be. Installing the Text Editor Syntax Highlighter plugin will equip the editor with syntax colouring, much like in a code editor.

https://wordpress.org/plugins/html-editor-syntax-highlighter/

Compatibility: WordPress 3.3 or higher

  1. Pre-Populate with Content

A great way to input the same content into each new post or page is through the Pre Populate Post Type Content plugin:

http://www.paulund.co.uk/pre-populate-post-type-content

Compatibility: WordPress 1.5

  1. Applying SSL In WordPress Multisite

SSL is a standard of website security. It not only ensures a safe connection between web server and browser, but also helps to bump you up in Google. It is a little more difficult to enforce when operating from a WordPress multisite with multiple sub-domains, so here’s an easy guide from wpmudev:

https://premium.wpmudev.org/blog/ssl-domain-mapping/

John Hewick

Author John Hewick

More posts by John Hewick