I want to remove the meta date from being displayed by Google's search. I came across this code usually found in single.php
<?php the_time(‘M j, Y’);?>
Needs to be re-written as:
<script language=”javascript” type=”text/javascri开发者_运维知识库pt”> document.write(‘<?php the_time(‘j’) ?>’); </script> <?php the_time(‘M Y’) ?>
However my single.php uses this format
<?php the_time(get_option('date_format')); ?>
How can I use javascript for the above code?
<script language=”javascript” type=”text/javascript”> document.write(‘<?php the_time(get_option("date_format")); ?>’);</script>
That will conceal the entire date, not just the day-of-the-month. (Is that what you want?)
Although one liner would work, code written up like this leads to code clutterage. You code should be read and easy to follow, like a book.
<?php
// the date() object should be used for this, and the following would normally by
// shoved in a function.
$date['j'] = the_time('j',get_option('date_format'));
$date['M'] = the_time('M', get_option('date_format'));
$date['Y'] = the_time('Y', get_option('date_format'));
// Build the date string the way want it
$date['full'] = "Today, the " . $date['j'] . "of " . $date['M'] . ", " . $date['Y'];
?>
<script language="javascript" type="text/javascript">document.write('<?php echo date["full"]; ?>');</script>
精彩评论