WordPress: Template Tags/single month title:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
无编辑摘要
无编辑摘要
第1行: 第1行:
== Description ==
== 描述 ==
== 描述 ==
Displays or returns the month and year title for the current page. This tag only works when the <code>m</code> or archive month argument has been passed by WordPress to the current page (this occurs when viewing a monthly archive page). Note: This tag only works on date archive pages, not on category templates or others.


为当前网页显示月份和年份标题。只有WordPress将<code>m</code>或者归档月份argument传到当前的网页的时候(当浏览按月归档的网页的时候,就会出现这种情况),这个标签才会运行。注:这个标签只在日期归档网页上运行,不在类别模板或者其它的模板上运行。
为当前网页显示月份和年份标题。只有WordPress将<code>m</code>或者归档月份argument传到当前的网页的时候(当浏览按月归档的网页的时候,就会出现这种情况),这个标签才会运行。注:这个标签只在日期归档网页上运行,不在类别模板或者其它的模板上运行。
 
== 用法 ==
== Usage ==


%%% <?php single_month_title('prefix', display) ?> %%%
%%% <?php single_month_title('prefix', display) ?> %%%


== 用法 ==
%%% <?php 单个_月份_标题('前缀', 显示) ?> %%%
The generated title will be:


产生的标题会是:
产生的标题会是:
第23行: 第13行:
  前缀+月份+前缀+年份
  前缀+月份+前缀+年份


If prefix parameter is <tt>'*'</tt>, an example would be:
如果前缀参数是<tt>'*'</tt>,例子就是:
如果前缀参数是<tt>'*'</tt>,例子就是:
*February*2004


*2004年*2月
*2004年*2月


== Examples ==
== 例子==
 
=== Month and Year on New Lines ===
 
= 例子==


=== 新的文本行中的年份和月份 ===
=== 新的文本行中的年份和月份 ===
Displays the title, placing month and year on new lines.


在新的文本行中显示标题,放置年份和月份。
在新的文本行中显示标题,放置年份和月份。


  &lt;p&gt;<?php single_month_title('&lt;br /&gt;') ?>&lt;/p&gt;
  &lt;p&gt;<?php single_month_title('&lt;br /&gt;') ?>&lt;/p&gt;
&lt;p&gt;<?php 单个_月份_标题('&lt;br /&gt;') ?>&lt;/p&gt;


<div style="border:1px solid blue; width:50%; padding:10px">December<br />
<div style="border:1px solid blue; width:50%; padding:10px">December<br />
第49行: 第29行:




<div style="border:1px 固体蓝; width:50%; padding:10px">十二月<br />
=== 使用  $my_month 变量 ===
2004</div>
 
 
=== Using $my_month Variable ===
 
=== 使用 $我的_月份 变数 ===


Returns the title, which is assigned to the $my_month variable. The variable's value is then displayed with the PHP echo command.
返回标题,这个标签指定到$my_month 变量。变量的值,就会与PHP echo命令一起显示。
 
返回标题,这个标签指定到$我的_月份 变数。变数的值,就会与PHP echo命令一起显示。


  <?php $my_month = single_month_title(&#39;&#39;, false); echo $my_month; ?>
  <?php $my_month = single_month_title(&#39;&#39;, false); echo $my_month; ?>
<?php $我的_月份 = 单个_月份_标题(&#39;&#39;, false); echo $我的_月份; ?>
== Parameters ==


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


; prefix : (''string'') Text to place before the title. There is no default.
; prefix : (''string'') 标题前显示的文本。没有默认设置。
; display : (''boolean'') Display the title (<tt>TRUE</tt>), or return the title to be used in PHP (<tt>FALSE</tt>).  Defaults to <tt>TRUE</tt>.
; display : (''boolean'')显示标题 (<tt>TRUE</tt>), 或者将标题返回用于PHP (<tt>FALSE</tt>).默认为 <tt>TRUE</tt>.
 
;前缀 : (''string'') 标题前显示的文本。没有默认设置。
; 显示 : (''boolean'') 显示标题(<tt>正确的</tt>), 或者将标题返回用于PHP(<tt>错误的</tt>)。 默认为 <tt>正确的</tt>。
 
== Related ==
 
{{Tag Date Tags}}
 
{{PHP Function Tag Footer}}


== 相关的 ==
== 相关的 ==

2008年7月12日 (六) 17:00的版本

描述

为当前网页显示月份和年份标题。只有WordPress将m或者归档月份argument传到当前的网页的时候(当浏览按月归档的网页的时候,就会出现这种情况),这个标签才会运行。注:这个标签只在日期归档网页上运行,不在类别模板或者其它的模板上运行。

用法

%%% <?php single_month_title('prefix', display) ?> %%%


产生的标题会是:

prefix + MONTH + prefix + YEAR
前缀+月份+前缀+年份

如果前缀参数是'*',例子就是:

  • 2004年*2月

例子

新的文本行中的年份和月份

在新的文本行中显示标题,放置年份和月份。

<p><?php single_month_title('<br />') ?></p>
December
2004


使用 $my_month 变量

返回标题,这个标签指定到$my_month 变量。变量的值,就会与PHP echo命令一起显示。

<?php $my_month = single_month_title('', false); echo $my_month; ?>

参数

prefix
(string) 标题前显示的文本。没有默认设置。
display
(boolean)显示标题 (TRUE), 或者将标题返回用于PHP (FALSE).默认为 TRUE.

相关的

模板:标签 日期 标签