Copy and paste it in functions.php file
<?php function date_year_shortcode()
{
$year = date('Y'); return $year;
}
add_shortcode('year', 'date_year_shortcode');
?>
display the year : [year]
if you want to use it on template , then use wordpress inbuilt function do_shortcode
<?php function date_year_shortcode()
{
$year = date('Y'); return $year;
}
add_shortcode('year', 'date_year_shortcode');
?>
display the year : [year]
if you want to use it on template , then use wordpress inbuilt function do_shortcode
<?php echo do_shortcode('[year]'); ?>
No comments:
Post a Comment