Changing the Post Date in Genesis 2.0 to use the Last Modified Date

chrislema-face

last-modified-dateCan I brag for a second?

I know, it's not normally cool to do that sort of thing. But here's the thing – I'm not bragging on myself. Except for one little part.

Ok, enough caveats – let the bragging begin.

I have some of the coolest and smartest friends. 

There it is. See, mostly it's not about me – except that networking and developing relationships does take a bit of work on my part. But these folks make it so easy.

I want to tell you about Syed.

He's the guy behind wpbeginner.com and he's smart. He's also an incredible hustler and if you read my post the other day, you know how much I value working hard.

Anyway, the other day he and I were talking about dates on articles and we both agreed that we should show the “last updated” dates on our posts. The only difference was that he'd done it on his site already and I hadn't.

That's ok, I don't mind losing to Syed. He's half my age and I'm already convinced he's done more than I will in a lifetime. So I've gotten used to expecting to lose. Plus, he gamifies everything. If you don't know what that means, you're lucky.

When I read his article about it, I was ready to do it. But of course, I'm using Genesis by StudioPress and Dynamik from Cobalt Apps.

That means Syed's article was close but not an exact match. That's not a problem when you're hosted on WP Engine because they give you a staging server where you can test everything you do without stress.

So that's what I did.

Hooks and Short Codes

Dynamik makes it really easy to hook into any spot within Genesis, so that's good news. If you don't know what that means, let me state it a bit more simply. Genesis isn't just a parent theme – it's a theme framework – coded in a way to let you insert, adjust, or generally tweak the code in ways they can't predict.

I said I'd say it more simply, but that didn't make it easier, did it? It's ok, I'll show you.

Now, on top of Genesis, I'm using Dynamik – which helps me adjust the look and feel without tons of CSS (though nothing stops me from using it).

And in this child theme, Dynamik gives me access to “Dynamik Custom” – where I can create my own short codes. So that's what I did.

Last_updatedIf you're looking to copy that code, it's this:

php
echo “Last updated on
the_modified_time(‘c');
echo ” itemprop='dateModified' class='entry-time'>”;
the_modified_time(‘F jS, Y');
echo “</time>”;
?>

But knowing the code doesn't explain what it does or how it works.

What it does

The code is doing three things at once.

The first thing is that it's replacing the original publish date for the last modified date. That's important so that when people get to one of my posts, they know how “fresh” it is.

The second thing it's doing is formatting the last modified date – twice. The second time you see “the_modified_time” you're seeing the format for how it will look for people on the screen.

The third thing it's doing is something powerful that I've started digging into more. See, on page SEO is all about giving Google (and other search engines) as many hints as you can about what your content says.

In the past, engines like Google would grab all the text and create it's own semantic mesh of the network of words on your page and what they knew of them. That's the network map they'd use to determine meaning.

But recently, and completely supported in Genesis 2.0, they've started letting us help them. That's what you see in the rest of the code above. It's the technical way to tell Google that this is the official last modified date and time. And that ‘c' in the formatting gives it the format that Google likes the best.

Can I tell you about my friend Robert?

If you're wondering how I got all that code right – particularly all the technical schema right for Google – I cheated. I called up my SEO friend, Robert Neu of  Fat Media.

While I knew schemas existed and that I needed to do it, I didn't know which parts, structures, and formats were best. He's a busy guy, but he's always willing to lend a hand. So in 10 minutes, he pointed me to the right spot.

Side note: when I tipped him a “thank you” via Paypal, do you think I calculated it based on how long it took him, or how long it would have taken me? I bet you know.

How it works

Now, for many folks, the Simple Edits plugin for Genesis is the easiest way to modify what shows up in your post meta. That's why I decided, when creating this bit of code, to turn it into a short code.

You'll see above that I named it last_updated. That let me use it in the Simple Edits screen, simply by replacing the previous date shortcode with the last_updated short code.

genesis-simple-edits

Could I have done something similar by just hooking my code to one of Genesis' many hooks? Yes, but since I was already using Simple Edits, the short code approach seemed the most consistent.

Conclusion

I blog regularly, so I'm not too worried about Google catching the change. But if I blogged less, I'd also be working to get some of my key articles re-indexed by Google so that they show a more recent date (the last modified date).

Thankfully, I'm not too worried, and that's all I had to do. Good luck! 

About Chris Lema

Chris Lema has been working with WordPress since 2005. Over the years he's been a blogger, a speaker at WordCamps, a coach for WordPress product companies, and the founder of the conference for WordPress business owners, called CaboPress. Today he's the VP of Products at Liquid Web, where he manages the world's first managed platform for WooCommerce stores.

Chris Lema

Chris Lema has been working with WordPress since 2005. Over the years he's been a blogger, a speaker at WordCamps, a coach for WordPress product companies, and the founder of the conference for WordPress business owners, called CaboPress. Today he's the VP of Products at Liquid Web, where he manages the world's first managed platform for WooCommerce stores.

Join more than 7,500 others

My posts. Your inbox. Beautiful.

Chris Lema Speaking

Do You Want To Pick My Brain?

Over the last few years, through private consulting, coaching, and using the pay-by-the-minute Clarity service, I've helped hundreds of folks like you solve their WordPress problems and overcome their technical challenges.

“In 18 minutes Chris was able to save me months of lost time and tens of thousands of dollars by directing me to the right technologies to create my course marketplace. The value was 100x what I paid.” — Josh

Have a question right now? Most of my Clarity calls last less than 20 minutes. Let's set up a call.