WordPress:Template Tags/get permalink

来自站长百科
Fludlen讨论 | 贡献2008年7月9日 (三) 13:58的版本
跳转至: 导航、​ 搜索

Description

描述

Returns the permalink to a post for use in PHP. It does NOT display the permalink and can be used outside of WordPress:The Loop.

返回一篇文章的permalink,用在PHP中。标签不显示permalinks,可以用在The Loop外。

Usage

用法

%%% <?php get_permalink(id); ?> %%%

%%% <?php get_permalink(id); ?> %%%

Examples

Default Usage

例子

默认用法

The permalink for current post (used within WordPress:The Loop). As the tag does not display the permalink, the example uses the PHP echo command.

当前文章的permalink(用在The Loop内)。因为标签不显示permalink,例子使用了PHP echo命令。

Permalink for this post:<br />
<?php echo get_permalink(); ?>

这篇文章的Permalink :<br />

<?php echo get_permalink(); ?>

Link to Specific Post

链接到某篇文章

Returns the permalinks of two specific posts (post IDs 1 and 10) as hypertext links within an informational list. As above, tag uses the PHP echo command to display the permalink.

返回两篇文章的permalinks(文章ID为1和10)作为信息列表内的超文本链接。如上所述,标签使用PHP echo 命令来显示permalink。

<ul>
<li>MyBlog info:
    <ul>
    <li><a href="<?php echo get_permalink(1); ?>">About MyBlog</a></li>
    <li><a href="<?php echo get_permalink(10); ?>">About the owner</a></li>
    </ul>
</li>
</ul>


<ul>

<li>MyBlog info:
    <ul>
    <li><a href="<?php echo get_permalink(1); ?>">About MyBlog</a></li>
    <li><a href="<?php echo get_permalink(10); ?>">About the owner</a></li>
    </ul>
</li>
</ul>


Parameters

参数

id
(integer) The numeric ID for a post. When this tag is used in WordPress:The Loop without an id parameter value, tag defaults to the current post ID.
id
(整数)文章的ID数字。在The Loop内使用这个标签,没有id参数值的时候,标签默认为当前文章ID。

Related

模板:Tag Permalink Tags

模板:Tag Footer

相关的

模板:标签Permalink标签

模板:标签页底文字