Created
January 2, 2019 17:41
-
-
Save DustinWStout/856fca14c415bb40007a60449d847724 to your computer and use it in GitHub Desktop.
WordPress Dynamic Year shortcode. Just add to your functions.php file and use the [year] shortcode in post titles and content.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//* Enable Post Meta Shortcode Support | |
add_filter( 'single_post_title', 'do_shortcode' ); | |
//* Enable Post Title Shortcode | |
add_filter( 'the_title', 'do_shortcode' ); | |
//* Current Year In Post Title Shortcode | |
add_shortcode( 'year' , 'current_year' ); | |
function current_year() { | |
$year = date("Y"); | |
return "$year"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment