WordPress: Template Tags/get month link:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: == Description == Returns the monthly archive URL to a specific year and month for use in PHP. It does NOT display the URL. ...)
 
无编辑摘要
第1行: 第1行:
== Description ==
== Description ==
== 描述 ==


Returns the monthly archive [[WordPress:Glossary#URI and URL|URL]] to a specific year and month for use in [[WordPress:Glossary#PHP|PHP]]. It does NOT display the URL. If year and month parameters are set to <tt>&#39;&#39;</tt>, the tag returns the URL for the current month's archive.
Returns the monthly archive [[WordPress:Glossary#URI and URL|URL]] to a specific year and month for use in [[WordPress:Glossary#PHP|PHP]]. It does NOT display the URL. If year and month parameters are set to <tt>&#39;&#39;</tt>, the tag returns the URL for the current month's archive.
返回某年某月的归档[[WordPress:Glossary#URI and URL|URL]],用于[[WordPress:Glossary#PHP|PHP]]中。不显示URL。如果年份和月份参数设置为<tt>&#39;&#39;</tt>,标签向当前月份归档返回了URL。


== Usage ==
== Usage ==
== 用法 ==
%%% <?php get_month_link('year', 'month'); ?> %%%


%%% <?php get_month_link('year', 'month'); ?> %%%
%%% <?php get_month_link('year', 'month'); ?> %%%


== Examples ==
== Examples ==
== 例子==


=== Month Archive as Link ===
=== Month Archive as Link ===
=== 每月归档作为链接 ===


Returns the URL to the current month's archive as a link by displaying it within an anchor tag with the PHP echo command.  
Returns the URL to the current month's archive as a link by displaying it within an anchor tag with the PHP echo command.  
返回当月存档的URL,作为链接,将这个URL放到一个anchor标签中和PHP echo命令一起显示。


  &lt;a href="<?php echo get_month_link(<nowiki>''</nowiki>, <nowiki>''</nowiki>); ?>"&gt;All posts this month&lt;/a&gt;
  &lt;a href="<?php echo get_month_link(<nowiki>''</nowiki>, <nowiki>''</nowiki>); ?>"&gt;All posts this month&lt;/a&gt;
&lt;a href="<?php echo get_month_link(<nowiki>''</nowiki>, <nowiki>''</nowiki>); ?>"&gt;All posts this month&lt;/a&gt;


=== Assigning Specific Month to Variable ===
=== Assigning Specific Month to Variable ===
=== 将某月指定为变数 ===


Returns URL to the archive for October 2004, assigning it to the variable $oct_04. The variable can then be used elsewhere in a page.
Returns URL to the archive for October 2004, assigning it to the variable $oct_04. The variable can then be used elsewhere in a page.
返回2004年10月存档的URL,将这个URL指定为变数$04年_10月,变数就可以用在网页的其它位置。


  <?php $oct_04 = get_month_link('2004', '10'); ?>
  <?php $oct_04 = get_month_link('2004', '10'); ?>
<?php $oct_04 = get_month_link('2004', '10'); ?>


=== Use With PHP Variables ===
=== Use With PHP Variables ===
=== 与PHP 变数一起使用 ===


PHP code block for use within [[WordPress:The Loop]]: Assigns year and month of a post to the variables $arc_year and $arc_month. These are used with the get_month_link() tag, which returns the URL as a link to the monthly archive for that 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.
PHP code block for use within [[WordPress:The Loop]]: Assigns year and month of a post to the variables $arc_year and $arc_month. These are used with the get_month_link() tag, which returns the URL as a link to the monthly archive for that 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_年份和 $arc_月份。这些变数与get_month_link()标签一起使用,get_month_link()标签返回URL作为一个链接,连接到文章的每月存档中,在一个anchor 标签中,将它和PHP echo命令一起显示。请看看[[WordPress:Formatting Date and Time|日期和时间格式]],有关用在[[WordPress:Template Tags/get_the time|get_the_time()]]标签中的格式字符串的信息。


  <?php
  <?php
第31行: 第57行:
  &lt;a href="<?php echo get_month_link(<nowiki>"$arc_year"</nowiki>, <nowiki>"$arc_month"</nowiki>); ?>"&gt;archive
  &lt;a href="<?php echo get_month_link(<nowiki>"$arc_year"</nowiki>, <nowiki>"$arc_month"</nowiki>); ?>"&gt;archive
  for <?php the_time('F Y') ?>&lt;/a&gt;
  for <?php the_time('F Y') ?>&lt;/a&gt;
<?php
$arc_year = get_the_time('Y');
$arc_month = get_the_time('m');
?>
&lt;a href="<?php echo get_month_link(<nowiki>"$arc_year"</nowiki>, <nowiki>"$arc_month"</nowiki>); ?>"&gt;archive
for <?php the_time('F Y') ?>&lt;/a&gt;


== Parameters ==
== Parameters ==
== 参数==


; year : (''integer'') The year for the archive. Use <tt>&#39;&#39;</tt> to assign current year.
; year : (''integer'') The year for the archive. Use <tt>&#39;&#39;</tt> to assign current year.
; 年份 : (''整数'')归档的年份。使用<tt>&#39;&#39;</tt>指定当前的年份。
; month : (''integer'') The month for archive. Use <tt>&#39;&#39;</tt> to assign current month.
; month : (''integer'') The month for archive. Use <tt>&#39;&#39;</tt> to assign current month.
; 月份 : (''整数'')归档的月份。使用<tt>&#39;&#39;</tt>指定当前的月份。


== Related ==
== Related ==
第42行: 第86行:


{{PHP Function Tag Footer}}
{{PHP Function Tag Footer}}
== 相关的 ==
{{标签 链接标签}}
{{PHP函数标签 页底文字}}

2008年7月5日 (六) 17:30的版本

Description

描述

Returns the monthly archive URL to a specific year and month for use in PHP. It does NOT display the URL. If year and month parameters are set to '', the tag returns the URL for the current month's archive.

返回某年某月的归档URL,用于PHP中。不显示URL。如果年份和月份参数设置为'',标签向当前月份归档返回了URL。

Usage

用法

%%% <?php get_month_link('year', 'month'); ?> %%%

%%% <?php get_month_link('year', 'month'); ?> %%%

Examples

例子

Month Archive as Link

每月归档作为链接

Returns the URL to the current month's archive as a link by displaying it within an anchor tag with the PHP echo command.

返回当月存档的URL,作为链接,将这个URL放到一个anchor标签中和PHP echo命令一起显示。

<a href="<?php echo get_month_link('', ''); ?>">All posts this month</a>

<a href="<?php echo get_month_link('', ''); ?>">All posts this month</a>

Assigning Specific Month to Variable

将某月指定为变数

Returns URL to the archive for October 2004, assigning it to the variable $oct_04. The variable can then be used elsewhere in a page.

返回2004年10月存档的URL,将这个URL指定为变数$04年_10月,变数就可以用在网页的其它位置。

<?php $oct_04 = get_month_link('2004', '10'); ?>

<?php $oct_04 = get_month_link('2004', '10'); ?>

Use With PHP Variables

与PHP 变数一起使用

PHP code block for use within WordPress:The Loop: Assigns year and month of a post to the variables $arc_year and $arc_month. These are used with the get_month_link() tag, which returns the URL as a link to the monthly archive for that 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 get_the_time() tag.

The Loop内使用的PHP代码块:将一篇文章的年份和月份指定为变数$arc_年份和 $arc_月份。这些变数与get_month_link()标签一起使用,get_month_link()标签返回URL作为一个链接,连接到文章的每月存档中,在一个anchor 标签中,将它和PHP echo命令一起显示。请看看日期和时间格式,有关用在get_the_time()标签中的格式字符串的信息。

<?php
$arc_year = get_the_time('Y');
$arc_month = get_the_time('m');
?>
<a href="<?php echo get_month_link("$arc_year", "$arc_month"); ?>">archive
for <?php the_time('F Y') ?></a>

<?php

$arc_year = get_the_time('Y');
$arc_month = get_the_time('m');
?>
<a href="<?php echo get_month_link("$arc_year", "$arc_month"); ?>">archive
for <?php the_time('F Y') ?></a>


Parameters

参数

year
(integer) The year for the archive. Use '' to assign current year.


年份
(整数)归档的年份。使用''指定当前的年份。


month
(integer) The month for archive. Use '' to assign current month.
月份
(整数)归档的月份。使用''指定当前的月份。


Related

模板:Tag Link Tags

模板:PHP Function Tag Footer

相关的

模板:标签 链接标签

模板:PHP函数标签 页底文字