So you’ve set up a site or two and think “That’s it – I’ve mastered WordPress!” However, the number of secrets on this powerful CMS is astounding. I’ve been writing WordPress tutorials for 8 years, and I’m still learning new tricks! Here are some of the most useful I’ve found so far. These six tricks will teach you a lot about how WordPress works, and give you a taste of its power.

Trick 1: Insert Google Analytics Without a Plugin

WordPress has a plugin for everything. However, they can accumulate pretty quickly and slow your site down. Some web hosts like SiteGround even limit the number of scripts you can execute, so keeping the absolute number of plugins low is good for your site.

Everyone uses Google Analytics. However, integrating it into WordPress requires either a plugin or theme support if you don’t want to modify the theme. But don’t worry! The code below will add your Google Analytics code automatically:

if ( !function_exists( 'tt_insert_analytics' ) ) {
	function tt_insert_analytics() { ?>
		<!-- Global site tag (gtag.js) - Google Analytics -->
		<script async src=""></script>
		  window.dataLayer = window.dataLayer || [];
		  function gtag(){dataLayer.push(arguments);}
		  gtag('js', new Date());
		  gtag('config', 'XX-XXXXXXXX-X');
	<?php }
	add_action( 'wp_head', 'tt_insert_analytics' );

Trick 2: Limit the Number of Post Revisions in WordPress

If you have a post or page in WordPress that’s updated frequently, eventually, you’ll see something like this:

Limit the Number of Post Revisions in WordPress

These are post revisions, and they store a copy of all the previous edits made to the article. It’s a great feature that allows you to keep track of what’s changed and revert to any version if necessary. The problem, however, is that these revisions can accumulate over time and clutter up your database, leading to a bloated system.

Chances are that you want to retain this feature, but don’t want post revisions going back years with potentially hundreds of entries for individual posts. The great thing is that we can limit these revisions.

Add the following line in your wp-config.php file which you can find in the in the root folder if your WordPress installation:

define( 'WP_POST_REVISIONS', 6 );

Replace 6 with the number of post revisions you want to store. Make sure you add this line before the section in wp-config.php which says:

/* That's all, stop editing! Happy blogging. */

Save your changes and you’re done! WordPress will now limit post revisions only to the specified number (plus one for the autosave). The best of both worlds!

Trick 3: Enable Lazy Loading of Images

Images form the bulk of page sizes. They’re also crucial to improving readability and increasing user engagement. But when you have a lot of them in your WordPress posts, they can really slow things down. This is because the page “waits” until the images have all appeared on screen before rendering.

Even when served from lightning fast geolocated CDNs, image load time can be huge. Which is where “lazy loading” comes in. Lazy loading ensures that the images are only downloaded when the user scrolls low enough to see them. That way, you’re not wasting precious time and bandwidth on images that will never be viewed.

It increases page load time dramatically, and we can implement it easily with the Jetpack plugin. You can download Jetpack from the WordPress plugin repository for free. Once installed with an account, go to your Dashboard, then Jetpack -> Settings as shown here:

Jetpack plugin

Then use the search functionality at the top right to search for “lazy”. This will reveal the section for lazy loading:

Enable Lazy Loading in WordPress

Just enable the option and you’re done!

Trick 4: Allow Shortcodes in Widget Areas

The ability to use shortcodes in WordPress is amazing. Content is no longer static but can be dynamically programmed. Unfortunately, we can’t use shortcodes by default in widgets. This means that your sidebar will always show the same content unless it’s specifically managed by a plugin.

For example, here’s a sample shortcode I inserted into a plugin:

Inserting Shortcode in Widget

And this is how it displays on my website:

Shortcode Doesnt Work

As you can see, the shortcode renders “as is”. It doesn’t execute. However, you can add the following code in your functions.php file or custom PHP plugin:

add_filter( 'widget_text', 'do_shortcode' );

And after you save the changes, the shortcode now works!

Shortcode Now Working

Isn’t that a great tweak for such a simple line?

Trick 5: Enable Custom Logos for your Theme

A logo is a unique image representing your page. You see them on all famous sites – usually in the header. Lots of themes have this option built-in by default – they allow you to specify a logo and will automatically resize it to various dimensions for use in prominent places.

You can tell if your theme supports custom logos by going to your WordPress dashboard, then Appearance -> Customize, navigating to the Site Identity section. If your theme doesn’t support custom logos, there won’t be a separate section for them as shown here:

No Custom Logo WordPress

This is unfortunate, but no need to panic. Using this simple code, we can enable support for site logos in your theme so that it shows up:

add_theme_support( 'custom-logo', array(
	'height' => 150,
	'width'  => 121,
) );

Add this code to your functions.php file and save your changes. Now when you navigate to the same section, you’ll see a new area for site logos as shown here:

New Logo Area in WordPress

Just click Select logo, upload your image and you’re good to go! You can then display it wherever you want using this PHP statement:


Isn’t that neat?

Trick 6: Exclude a Category from the Front Page

By default, the front page shows all posts. However, you might not want all categories to be displayed on the front blog page. To do this, we first need to get the category number for the categories we want to exclude.

Go to your WordPress dashboard and open the categories page from Posts->Categories as shown here:

Exclude a Category from the Front Page WordPress

This will display a list of categories on the right-hand side. Find the one you want and hover your mouse cursor over the Edit link below. Then look at the status bar. You’ll see the category ID in the URL. In this case, the ID for category NF is 15.

Now that you know the category number, copy and paste the following code into functions.php:

if ( !function_exists( 'tt_exclude_pages_from_front' ) ) {
	function tt_exclude_pages_from_front( $query ) {
		if ( $query->is_home() && $query->is_main_query() ) {
			$query->set( 'cat', '-15' );
	add_action( 'pre_get_posts', 'tt_exclude_pages_from_front' );

Replace 15 with the category number you want to exclude. Remember to retain the minus (-) sign! You can exclude multiple categories from the homepage by separating the IDs with a comma (each one a minus).

Save your changes and you’re done. Now those categories will be hidden from the home page.

These tips and tricks are valid for all WordPress installations. All web hosts allow you to install WordPress automatically via cPanel. Some even have it pre-installed! You can find the cheapest web hosting on WP-Tweaks, which compares the pricing of hosting providers like SiteGround, Bluehost, and Hostgator.

Leave a Reply

Your email address will not be published. Required fields are marked *