Display Current Year in Wordpress
·
Answer a question
I need to display the current year in Wordpress, now this is already being done in the footer template using php:
<?php echo date('Y'); ?>
The site in question is for a car dealer. So there are many year model references in the page/post content ie.
<h1>2013 Volkswagen Polo</h1>
All of these need updated on the first of January each year. However the php code doesn't work within the page/post content, only in template files. So I need a different way to do this.
Any ideas?
Thanks in advance
Willem
Answers
Why don't you create the simple shortcode function for this purpose?
function currentYear( $atts ){
return date('Y');
}
add_shortcode( 'year', 'currentYear' );
Then you will be able to put [year] to anywhere in the content area.
更多推荐
所有评论(0)