Textpattern:copyright dates

Strictly speaking, every time a text is amended, the particular year should appear in the copyright notice i.e ©2010, 2012 for which case there is a plugin.

The following code features another method without using a plugin.

Use PHP to echo the year

<txp:variable name="year" value='<txp:php>echo safe_strftime("%Y");</txp:php>' />
<txp:if_variable name="year" value='<txp:posted format="%Y" />'>
&copy; <txp:variable name="year" />
<txp:else />
&copy; <txp:posted format="%Y" /> - <txp:variable name="year" /> 
</txp:if_variable>

The code detects if the article was posted this year and would therefore display &copy 2014.

If it was posted any year before the current year of 2014, then it will display that year and the current one – i.e © 2009 – 2014.

via: txptips by Yiannis Colakides

评论已关闭。Comments are turned off for this article.