Archived topic
Show updated post date only for visitors, not Google
3 replies · Started by Eber on December 18, 2022
Hello,
I would like to display the updated post date using Javascript, so that the dates wont appear on Google SERPs, but will for visitors.
Do you think this code will work to achieve that?
<script language="javascript" type="text/javascript">document.write("<?php the_time('F jS, Y') ?>");</script>
If yes, how can I insert it on my theme, so that it shows below the post title?
Thanks,
Hi Eber,
I believe SERPs run javascript as well, so if you add the date through Javascript, it will see it regardless.
So I think doing that wouldn't work for your intended result.
Here's something I found though which may help: https://stackoverflow.com/questions/15685205/noindex-tag-for-google#:~:text=You%20can%20prevent%20Google%20from%20seeing%20portions%20of%20the%20page%20by%20putting%20those%20portions%20in%20iframes%20that%20are%20blocked%20by%20robots.txt.
It may be good to ask an SEO expert regarding this as this would be out of our scope of expertise and support.
You can use try adding the time along this way of "hiding" through a Hook Element. Hook it to generate_after_entry_title.
Thanks!
You're welcome, Eber!