Link Template Tags 中函数的作用是在WordPress主题中生成相关链接,包括 Edit Post 链接、 Edit Comment 链接、Page 链接、Yearly Archive URL 、Monthly Archive URL、Daily Archive URL 、Previous Post Links。
一. Edit Post 链接——在用户登录的情况下,显示文章编辑链接
语法:<?php edit_post_link(‘link’, ‘before’, ‘after’); ?>
参数说明:
- link:链接文本,默认值为 Edit This,例:<?php edit_post_link(‘Edit’, ‘before’, ‘after’); ?>。
- before:链接文本前导符,默认值为空,例:<?php edit_post_link(‘link’, ‘»’, ‘after’); ?>
- after:链接文本后导符,默认值为空,例:<?php edit_post_link(‘link’, ‘before’, ‘«’); ?>
二. Edit Comment 链接——在用户登录的情况下,显示评论编辑链接
语法:<?php edit_comment_link(‘link’, ‘before’, ‘after’); ?>
参数说明:
- link:链接文本,默认值为 Edit This,例:<?php edit_comment_link(‘Edit’, ‘before’, ‘after’); ?>
- before:链接文本前导符,默认值为空,例:<?php edit_comment_link(‘link’, ‘»’, ‘after’); ?>
- after:链接文本后导符,默认值为空,例:<?php edit_comment_link(‘link’, ‘before’, ‘«’); ?>
三. Page Links——页面导航链接
语法:<?php wp_page_links(‘arguments’); ?>
参数说明:
- before:整个页面链接的前导符,默认值为<p>Pages:,例:<?php wp_page_links(‘before=<div>’); ?>
- after:整个页面链接的后导符,默认值为</p>,例:<?php wp_page_links(‘after=</div>’); ?>
- next_or_number:是否使用页码,参数范围 [number | next],例:<?php wp_page_links(‘next_or_number=next’); ?>
- nextpagelink:下一页链接文本,默认值为Next page,例:<?php wp_page_links(‘nextpagelink=Next’); ?>
- previouspagelink:前一页链接文本,默认值为Previous page,例:<?php wp_page_links(‘previouspagelink=Previous’); ?>
- pagelink:链接格式,%代表页码,例:<?php wp_page_links(‘pagelink=[%]’); ?>
- more_file:链接指向的页面,默认只向当前页面,例:<?php wp_page_links(‘more_file=more.php’); ?>
四. Yearly Archive URL —— 年份归档链接,供PHP调用
语法:<?php get_year_link(‘year’); ?>
参数说明:默认值为当前年份,例:<?php get_year_link(‘2003’); ?>
五. Monthly Archive URL——年份/月份归档链接,供PHP调用
语法:<?php get_month_link(‘year’,’month’); ?>
参数说明:
year:年份;month:月份
例:<?php get_month_link(‘2003′,’month’); ?> <?php get_month_link(‘2003′,’month’); ?>
六. Daily Archive URL 按天归档文件链接,供PHP 调用
语法:<?php get_day_link(‘year’,’month’,’day’); ?>
参数说明:
year:年份;month:月份;day:天
例:<?php get_day_link(‘year’,’month’,’23’); ?>