好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

WordPress 模板标签 the_permalink()

说明

该标签显示当前被主循环(loop)处理的文章的固定链接URL。the_permalink()必须用在主循环(loop)中,该标签通常用来显示页面上文章的固定链接。由于the_permalink()只能显示正在被主循环处理的文章的固定链接,因此用户无法用它来显示任意文章。如果你希望显示某篇文章的固定链接,并且你知道这篇文章的ID,可以考虑使用get_permalink()。

用法

<?php the_permalink(); ?>

参数

该标签无参数

示例

将文章URL作为文本形式显示(无链接)

以文本形式显示文章URL,不生成链接:

This address for this post is: <?php the_permalink(); ?>

任意链接文本

你可以选择任意文字作为链接文本,这里我们假设链接文本为“permalink”:

<a href=”<?php the_permalink(); ?>”>permalink</a>

将文章标题作为链接文本

生成固定链接,以文章标题作为链接文本。这是显示文章标题的常用方法。

<a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a>

历史记录

始见于 WordPress 1.2.0版本

源文件

the_permalinkr() 位于 中。

查看更多关于WordPress 模板标签 the_permalink()的详细内容...

  阅读:1424次