编辑“WordPress:Template Tags/get year link”
该编辑可以被撤销。 请检查下面的对比以核实您想要撤销的内容,然后发布下面的更改以完成撤销。
最后版本 | 您的文本 | ||
第1行: | 第1行: | ||
== Description == | |||
== 描述 == | == 描述 == | ||
Returns the yearly archive [[WordPress:Glossary#URI and URL|URL]] to a specific year for use in [[WordPress:Glossary#PHP|PHP]]. It does NOT display the URL. If year is set to <tt>''</tt>, the tag returns the URL for the current year's archive. | |||
返回某年的归档[[WordPress:Glossary#URI and URL|URL]],用于[[WordPress:Glossary#PHP|PHP]]中。不显示URL。如果年份设置为<tt>''</tt>,标签向当前年份归档返回了URL。 | 返回某年的归档[[WordPress:Glossary#URI and URL|URL]],用于[[WordPress:Glossary#PHP|PHP]]中。不显示URL。如果年份设置为<tt>''</tt>,标签向当前年份归档返回了URL。 | ||
== Usage == | |||
== 用法 == | == 用法 == | ||
%%% <?php get_year_link('year'); ?> %%% | %%% <?php get_year_link('year'); ?> %%% | ||
%%% <?php get_year_link('year'); ?> %%% | |||
== Examples == | |||
== 例子== | == 例子== | ||
=== Year as Link === | |||
=== 年份作为链接 === | === 年份作为链接 === | ||
Returns the URL for the current year's archive, displaying it as a link in the anchor tag by using the PHP echo command. | |||
返回当年存档的URL,使用PHP echo命令行,在anchor标签中显示URL为一个链接。 | 返回当年存档的URL,使用PHP echo命令行,在anchor标签中显示URL为一个链接。 | ||
<a href="<?php echo get_year_link(<nowiki>''</nowiki>); ?>">Posts from this year</a> | |||
<a href="<?php echo get_year_link(<nowiki>''</nowiki>); ?>">Posts from this year</a> | <a href="<?php echo get_year_link(<nowiki>''</nowiki>); ?>">Posts from this year</a> | ||
=== Year as a variable === | |||
=== 年份作为变数 === | === 年份作为变数 === | ||
Returns URL for the archive year 2003, assigning it to the variable $year03. The variable can then be used elsewhere in a page. | |||
返回2003年存档的URL,并且指派这个URL为变数$03年。变数可以在网页的其它位置上使用。 | 返回2003年存档的URL,并且指派这个URL为变数$03年。变数可以在网页的其它位置上使用。 | ||
<?php $year03 = get_year_link(2003); ?> | |||
<?php $year03 = get_year_link(2003); ?> | <?php $year03 = get_year_link(2003); ?> | ||
=== Using With PHP Variables === | |||
=== 与PHP 变数一起使用 === | === 与PHP 变数一起使用 === | ||
[[WordPress:The Loop|The Loop]]内可以使用的PHP代码块:将年份指定为变数$ | PHP code block for use within [[WordPress:The Loop]]: Assigns year to the variable $arc_year. This is used with the get_year_link() tag, which returns the URL as a link to the yearly archive for a post, displaying it within an anchor tag with the PHP echo command. See [[WordPress:Formatting Date and Time]] for info on format strings used in [[WordPress:Template Tags/get_the time|get_the_time()]] tag. | ||
[[WordPress:The Loop|The Loop]]内可以使用的PHP代码块:将年份指定为变数$arc_年份。变数在get_year_link()标签内部使用,这个标签返回URL作为一个链接,连接到文章的年份存档中,在一个anchor 标签中,将它和PHP echo命令一起显示。请看看[[WordPress:Formatting Date and Time|日期和时间格式]],有关用在[[WordPress:Template Tags/get_the time|get_the_time()]]标签中的格式字符串的信息。 | |||
<?php | |||
$arc_year = get_the_time('Y'); | |||
?> | |||
<a href="<?php echo get_year_link(<nowiki>$arc_year</nowiki>); ?>"><?php the_time('Y') ?> archive</a> | |||
<?php | <?php | ||
第29行: | 第58行: | ||
?> | ?> | ||
<a href="<?php echo get_year_link(<nowiki>$arc_year</nowiki>); ?>"><?php the_time('Y') ?> archive</a> | <a href="<?php echo get_year_link(<nowiki>$arc_year</nowiki>); ?>"><?php the_time('Y') ?> archive</a> | ||
== Parameters == | |||
== 参数== | == 参数== | ||
; year : (''integer'') 归档的年份。使用<tt>''</tt>指派当前的年份。 | ; year : (''integer'') The year for the archive. Use <tt>''</tt> to assign current year. | ||
; 年份 : (''整数'')归档的年份。使用<tt>''</tt>指派当前的年份。 | |||
== Related == | |||
{{Tag Link Tags}} | |||
{{PHP Function Tag Footer}} | |||
== 相关的 == | == 相关的 == |