WordPress:Template Tags/get permalink

来自站长百科
Xxf3325讨论 | 贡献2008年6月27日 (五) 10:52的版本 (新页面: == Description == Returns the permalink to a post for use in PHP. It does NOT display the permalink and can be used outside of...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

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.

Usage

%%% <?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 for this post:<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.

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

Related

模板:Tag Permalink Tags

模板:Tag Footer