Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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>
share|improve this answer
 
Thanks! :) that got me on the right track. –  momofone Dec 11 '11 at 20:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.