year shortcode wordpress

To create a custom shortcode for the current year in WordPress, follow these steps:

  1. Access your WordPress dashboard.
  2. Go to the theme folder by navigating to "Appearance" > "Theme Editor."
  3. Find the "functions.php" file in the theme files list.
  4. Open the "functions.php" file.
  5. Add the following code snippet at the end of the file:
function current_year_shortcode() {
    $year = date('Y');
    return $year;
add_shortcode('year', 'current_year_shortcode');
  1. Save the changes by clicking on the "Update File" button.
  2. You've now created a shortcode [year] that will display the current year when used within WordPress.

After implementing these steps, the shortcode [year] will dynamically output the current year wherever it is placed within your WordPress content.