编辑“WordPress:Template Tags/get year link

跳转至: 导航、​ 搜索
警告:您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您登录创建一个账户,您的编辑将归属于您的用户名,且将享受其他好处。

该编辑可以被撤销。 请检查下面的对比以核实您想要撤销的内容,然后发布下面的更改以完成撤销。

最后版本 您的文本
第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>&#39;&#39;</tt>, the tag returns the URL for the current year's archive.
返回某年的归档[[WordPress:Glossary#URI and URL|URL]],用于[[WordPress:Glossary#PHP|PHP]]中。不显示URL。如果年份设置为<tt>&#39;&#39;</tt>,标签向当前年份归档返回了URL。
返回某年的归档[[WordPress:Glossary#URI and URL|URL]],用于[[WordPress:Glossary#PHP|PHP]]中。不显示URL。如果年份设置为<tt>&#39;&#39;</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为一个链接。
&lt;a href="<?php echo get_year_link(<nowiki>''</nowiki>); ?>"&gt;Posts from this year&lt;/a&gt;


&lt;a href="<?php echo get_year_link(<nowiki>''</nowiki>); ?>"&gt;Posts from this year&lt;/a&gt;
&lt;a href="<?php echo get_year_link(<nowiki>''</nowiki>); ?>"&gt;Posts from this year&lt;/a&gt;
=== 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代码块:将年份指定为变数$arc_year。变数在get_year_link()标签内部使用,这个标签返回URL作为一个链接,连接到文章的年份存档中,在一个anchor 标签中,将它和PHP echo命令一起显示。请看看[[WordPress:Formatting Date and Time|日期和时间格式]],有关用在[[WordPress:Template Tags/get_the time|get_the_time()]]标签中的格式字符串的信息。
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');
?>
&lt;a href="<?php echo get_year_link(<nowiki>$arc_year</nowiki>); ?>"&gt;<?php the_time('Y') ?> archive&lt;/a&gt;


<?php
<?php
第29行: 第58行:
  ?>
  ?>
  &lt;a href="<?php echo get_year_link(<nowiki>$arc_year</nowiki>); ?>"&gt;<?php the_time('Y') ?> archive&lt;/a&gt;
  &lt;a href="<?php echo get_year_link(<nowiki>$arc_year</nowiki>); ?>"&gt;<?php the_time('Y') ?> archive&lt;/a&gt;
== Parameters ==


== 参数==
== 参数==


; year : (''integer'') 归档的年份。使用<tt>&#39;&#39;</tt>指派当前的年份。
; year : (''integer'') The year for the archive. Use <tt>&#39;&#39;</tt> to assign current year.
 
; 年份 : (''整数'')归档的年份。使用<tt>&#39;&#39;</tt>指派当前的年份。
 
== Related ==
 
{{Tag Link Tags}}


{{PHP Function Tag Footer}}


== 相关的 ==
== 相关的 ==
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅Wordpress-mediawiki:版权的细节)。 未经许可,请勿提交受版权保护的作品!
取消 编辑帮助(在新窗口中打开)