WordPress全自动更新网站底部版权Copyright©年份,WordPress底部版权年份自动更新教程

Wordpress3年前 (2022)发布 SUYEONE
2K 0 0

Updating the copyright year in a WordPress footer annually can be a tedious task, especially for personal blogs that aren’t as frequently maintained as corporate websites. However, managing multiple business sites requires efficient upkeep. Today, I’ll share a couple of methods to automate this process, sparing you the effort and potential oversight.

There are two approaches to dynamically update the copyright year: using JavaScript or leveraging PHP. Since WordPress is built on PHP, we’ll lean more towards the latter, as it’s less prone to issues caused by function blocking or caching.

Here’s the PHP code to display the current year:
“`php

“`
And here’s the JavaScript alternative:
“`html
document.write(new Date().getFullYear())
“`

For instance, you can integrate these into your WordPress footer like this:
“`html
Copyright © 2014 – <a href="”>
“`
In this example, `©` is represented by `©`, “ retrieves your site’s URL for a hyperlink, and “ fetches your site’s title.

Feel free to modify the content according to your needs. Whether you prefer hardcoding or utilizing WordPress functions for customizability depends on your specific site and its history. While this might seem trivial for some, it can save time and hassle, particularly for those with older sites where改动主机或站点信息的情况较少发生. Enjoy the convenience!

© 版权声明

相关文章

暂无评论

暂无评论...
☺一键登录开启个人书签等功能!