0

For my wordpress website I am trying to remove the Google timestamp that is currently in my SERP (search page result description.)

To do this I must use javascript to get the time and report it back.

You may want to refer to this link: http://www.andrewkeir.com/remove-wordpress-post-datestamp-timestamp-google-serps/

and to another question here: Need to insert javascript into php code [Wordpress Website]

The code in my template file is:

$out .= '<div class="info"><a class="date-left"></a><a href="'.get_month_link($year, $month).'" class="date">'.get_the_time('F j, Y').'</a><a class="date-right"></a>

and I need to get this code to work in its place:

<script language="javascript" type="text/javascript">document.write("<?php the_time('F jS, Y') ?>");</script>

Appreciate any help/guidance on how to do this.

1 Answer 1

0

Basically that first article you referenced is telling you that you need to wrap the code that determines the time using PHP (in your case the "get_the_time('F j, Y')" part) with Javascript that will write the exact same output to the document. Therefore if you take your existing code:

$out .= '<div class="info"><a class="date-left"></a><a href="'.get_month_link($year, $month).'" class="date">'.get_the_time('F j, Y').'</a><a class="date-right"></a>

You'll probably want to do something like this:

$out .= '<div class="info"><a class="date-left"></a><a href="'.get_month_link($year, $month).'" class="date"><script language="javascript" type="text/javascript">document.write('.get_the_time('F j, Y').');</script></a><a class="date-right"></a>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.