Quantcast
Channel: Web Design from Scratch » WordPress
Viewing all articles
Browse latest Browse all 10

How to Remove Dates from SERP Snippets in WordPress to Increase Clickthrough Rate

$
0
0

Ben posted recently about how removing the date from SERP snippets on older posts helped us recover a lot of traffic we had inadvertently lost several months previously.

In this tutorial I’ll show you how we removed the dates, and set up an option to keep the dates in for ‘time-sensitive’ posts.

Why remove the date?

First things first, why would we want to remove the date from the SERP snippet at all?

As Ben explained in his article, if someone sees your post in the search results, but it is dated several years ago, they are much less likely to click through to the page, as they may assume that the information there will be out of date.

This is fair enough for searches that are ‘time-sensitive’, for example if you’re searching for recent news, you don’t want to read articles from last year. This is why we added an option to keep the date if desired (which I will explain later).

But certain types of post are ‘timeless’ and would be as relevant today as they were 5 years ago. For example Ben’s article about why you should code by hand. The article was written in 2006, but the message is still relevant today, therefore we would choose not to display the date on this post, in case people wrongly assume that the content will be out of date.

At the same time, if a search result shows a recent date, then this is more likely to encourage clickthroughs, which is why we only remove the date after the article is three months old.

Where does Google get the date from?

To remove the date from the SERPs, we need to know where Google gets it from in the first place. I read a number of different articles on the subject, which said that Google can find the date on a WordPress post from the the_date() function, or failing that, from the date of comments or the content of the post itself.

However, looking at the page source, I found that the only place the full date appeared was directly after the main heading, from the the_date() function, so I figured removing this should be sufficient.

How to keep the date

We decided that more often than not, we would want to hide the date, so we made that the default. But as I mentioned earlier, we wanted an option to keep the date on a post if we felt readers would benefit from knowing the date of publication.

We do this through a custom field, which I’ll call add-date. So if you want to keep the date, you add the add-date custom field, and give it a value (any value will do, as we will only check whether the field exists or not, but for the sake of consistency I use a Y as the value).

Note: If you prefer, you can add a meta box to the Edit Post page and make this custom field into a checkbox, as pictured below. If you don’t know how to code that, the Custom Fields plugin makes it very simple.

add-date-meta-box

How our 'Add date' option appears in the post editor

Making it work

Now all we need is a bit of PHP to make it all work.

We start with the date function:

Select All Code:
1
<?php the_date(); ?>

Then we add a conditional statement which only shows the date if the post is less than 90 days old:

Select All Code:
1
2
3
<?php if(strtotime( get_the_date() ) > strtotime( "90 days ago" )) {
        the_date();
} ?>

And finally, we add another condition, so that if the post is less than 90 days old OR our add-date custom field exists, then the date is shown:

Select All Code:
1
2
3
<?php if((get_post_meta($post->ID, 'add-date', true)) || strtotime( get_the_date() ) > strtotime( "90 days ago" )) {
        the_date();
} ?>

And that’s it! You can change the 90 days bit to whatever time period you prefer.

The verdict

So within about a week of implementing this, the dates had gone from all of our selected SERP snippets, and as shown in Ben’s article, our traffic is on the rise. Yay!

The post How to Remove Dates from SERP Snippets in WordPress to Increase Clickthrough Rate appeared first on Web Design from Scratch.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images