Adding dynamic copyright year into pages
-
Hello,
What I did: I added the below code to my WordPress pages (Text mode), so the current year will be displayed, and automatically updated each year. The code works, in Text mode I click the button Update and the copyright notice is nicely displayed in the website, with the current year in it.
—-
Issue: However, when I change the page from Text mode into Visual mode, WordPress will automatically change the code pasted into the page. When I get back to Text mode, the code is corrupted. This means that everytime I update the text in a page, the copyright code at the end of the text will be corrupted by WordPress.
—–
Question: Is there any way to improve avoid the code below, so it will not change by WordPress, when I change the page from Text mode into Visual mode in the Dashboard? Many thanks.© <?php $copyYear = 2007; // Set your website start date $curYear = date('Y'); // Keeps the second year updated echo $copyYear . (($copyYear != $curYear) ? '-' . $curYear : ''); ?> Copyright, all rights reserved <a title="MyWebsite" href="http://mydomain.com/">MyWebsite</a> | <a title="Contact" href="https://mydomain.com/?page_id=259">Contact</a>
The topic ‘Adding dynamic copyright year into pages’ is closed to new replies.