get_month_link()获取月份存档页面链接

目录

描述

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.

In a Plugin or Theme, it can be used as early as the setup_theme Action. Any earlier usage, including plugins_loaded, generates a Fatal Error.

get_month_link() 描述

用法

 <?php get_month_link$year$month ); ?> 

get_month_link() 用法

参数

year

(boolean/integer) (可选) The year for the archive. Use '' to assign current year.

默认值: None

month

(boolean/integer) (可选) The month for the archive. Use '' to assign current month.

默认值: None

get_month_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.

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.

Use With PHP Variables

PHP code block for use within 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 Formatting Date and Time for info on format strings used in get_the_time() tag.

get_month_link() 示例

源文件

get_month_link() 函数的代码位于 wp-includes/link-template.php.

get_month_link() 源文件

相关