How to Modify the functions.php File in WordPress.
1. Log in to the WordPress admin area.
2. Go to Appearance > Theme Editor in the left sidebar.
![](https://prakashtyata.com.np/wp-content/uploads/2023/08/theme-editor.webp)
3. Make sure you’re modifying the child theme, not the main theme, in the upper right corner.
4. Select the functions.php file from the right sidebar.
5. Add the following piece of code to the file.
function display_year() {
$year = date('Y');
return $year;
}
add_shortcode('year', 'display_year');
6. The file should be saved or updated.
You can now utilize the [year] shortcode in your WordPress widgets.