Increase Wordpress Page Load Speed

Replace SEO plugins with Custom Fields

Last Updated Please share our content if it is helpful

A fast loading time is now becoming important to both users AND search engines.

Looking at three of our sites with the P3 Plugin Performance Profiler, we saw that All In One SEO Pack was taking .431 seconds to load (one site) whereas (on two different sites) Yoast WordPress SEO was taking .6189 seconds and .86 seconds to load.

These plugins are incredibly popular but they are NOT necessary for most SEO. By copying and pasting some simple code, anyone can get rid of them and yet still have a different title tag and meta description for each page and post.

Note: The official WordPress advice on meta tags is that it is not necessary to have a different Meta Description and Meta Keywords for each page. They recommend having a static, generic Meta Description for all pages (and Meta Keywords if used) and creating the title tag by adding the following code into header.php:

<title><?php bloginfo(‘name’); ?><?php wp_title(); ?></title>

Depending how your theme is coded, this is likely to lead to posts having the same title tag and H1 (Heading1) – not a good idea for SEO.

Post title becomes H1 and Title tag

Having the same Meta Description for each page is often not optimal for websites either.

Google no longer uses Meta Keywords although a few smaller search engines might still do so.

Custom Fields for SEO

We found that by creating two custom fields and adding a few lines of code into out header.php, we could eliminate the need for SEO plugins.

Step 1

Create two custom fields within your page (or post). Once created, these fields can be used for each page or post.

Custom fields for title tag and meta description

Step 2

Insert the following code into your header.php file

<!– if titletag is filled in, use this; else use post title–>
<title><?php $titletag = get_post_meta($post->ID, ‘titletag’, true);
if ($titletag) {?><?php echo $titletag?><?php }
else {?><?php wp_title(”); ?><?php }?></title>

<!– if metadescription is filled in, use this; else use generic default description–>
<meta name=”description” content=”<?php $metadescription = get_post_meta($post->ID, ‘metadescription’, true);
if ($metadescription) {?><?php echo $metadescription?><?php }
else {?>Insert generic default description if no description custom field is present<?php } ?>” />

Optionally, the same principle could be used for meta keywords.

Note: As with any php queries, there might be some slight overhead to this – but we found that getting rid of these SEO plugins was one component in reducing the load time of a customer site from 7 – 1 5 seconds to less than 1 second. When we ran a test site through the Pingdom Speed Test, we found the following average loading times:

.36 seconds = using custom fields for titletag and metadescription

.43 seconds = using WordPress’s recommended method (see above)

1.3 seconds = Yoast SEO plugin (on some tests, pages loaded quickly, other times they did not; for this test site, the P3 Performance Profiler stated that Yoast SEO took .87 seconds to load on average.)

Replace Other Plugins with Custom Fields

The same principle can be used to replace some of those other time-guzzling plugins with custom fields.

On this site, we sometimes use a different top masthead image without using a plugin. We simply have a custom field called (for example) toppic:

Toppic custom field is used to have a different top image in the masthead of each page without a plugin

and then some code in our header.php that says that, if toppic is completed, use it; else use a generic image.

<img class=”tips” alt=”Web design tips and tricks” src=”<?php $toppic = get_post_meta($post->ID, ‘toppic’, true);
if ($toppic) {
?>
<?php echo $toppic?>
<?php } else { ?>http://uniquewebsites.co.uk/blog/wp-content/themes/UniqueWebsites/images/webdesign-seo-socialmedia.png<?php } ?>” width=”100%;” />

Elsewhere in this blog, we have used the same principle to insert an additional image into the sidebar of some (not all) posts.

Please share our content if it is helpful

Tags: , ,