Permalink Template Tags 中函数的作用是在WordPress主题中生成固定链接,包括Permalink Anchor、 Permalink (PHP) 、Permalink URL 、Permalink(formatted for syndication feeds)。
一. Permalink Anchor——输出带有标识符的文章链接
语法:<?php permalink_anchor(‘type’); ?>
参数说明:type[id|title]
id——post ID
tile——postname
输出样式<a id=”….
例:<?php permalink_anchor(‘type=title’); ?>
二. Permalink (PHP)——在php中调用文章permalink
语法:<?php get_permalink(id); ?>
参数说明:
id——文章ID(post ID),若函数用于循环(loop)内,并且没有指定id时,id默认取值当前文章的post ID。
例:<?php get_permalink(17); ?>
三. Permalink URL——文章固定链接
语法:<?php the_permalink(); ?>
参数说明:无参数,此函数必须用于循环(loop)中,返回正在处理的文章固定链接。
四. Permalink(formatted for syndication feeds)
语法:<?php permalink_single_rss(‘file’); ?>
参数说明:
file——链接指向的页面,默认为当前页。
例:<?php permalink_single_rss(‘index.php’); ?>