Title: Permalink Shortcode
Author: Ryan
Published: <strong>2013 年 5 月 2 日</strong>
Last modified: 2013 年 5 月 2 日

---

搜索插件

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://s.w.org/plugins/geopattern-icon/permalink-shortcode.svg)

# Permalink Shortcode

 作者：[Ryan](https://profiles.wordpress.org/rlange/)

[下载](https://downloads.wordpress.org/plugin/permalink-shortcode.1.0.0.zip)

 * [详情](https://cn.wordpress.org/plugins/permalink-shortcode/#description)
 * [评价](https://cn.wordpress.org/plugins/permalink-shortcode/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/permalink-shortcode/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/permalink-shortcode/#developers)

 [支持](https://wordpress.org/support/plugin/permalink-shortcode/)

## 描述

Permalink Shortcode is a relatively simple plugin that implements a shortcode that
you can use to link to existing posts and pages on your site. The shortcode also
supports a number of HTML attributes (see below).

While WordPress does include a feature that allows you to link to existing content,
this feature only inserts a “static” link. If you were to change the slug for that
post or page, previously inserted links would no longer be valid.

The permalink shortcode can be used in two forms:

 1. Standard: `<a href="[permalink wpid='123']">link text</a>`
 2. Enclosing: `[permalink wpid="123"]link text[/permalink]`

(Note the single quotes used in the standard form example above. Using double quotes
in this situation will not work.)

#### Supported Attributes

The following attributes are available in both the shortcode’s standard form and
its enclosing form:

 * `wpid`: The ID number of the post or page to which you want a link.
 * `query`: The part of a URL that comes after the ‘?’ (e.g. “?foo=bar”). The ‘?’
   is optional and will be added automatically if not included.
 * `fragment`: The part of the URL that comes after the ‘#’ (e.g. “#comments”). 
   The ‘#’ is optional and will be added automatically if not included.

The following HTML attributes are available only in the shortcode’s enclosing form:

 * `accesskey`
 * `charset`
 * `class`
 * `dir`
 * `hreflang`
 * `id`
 * `lang`
 * `media`
 * `rel`
 * `rev`
 * `style`
 * `target`
 * `title`
 * `type`

Things to be aware of with some of the above attributes:

 * In the enclosing form, the CSS class name `permalink-shortcode` is always added
   to the `class` attribute, even if you don’t specify any class names yourself.
 * In the enclosing form, if no value is given for the `title` attribute, the post
   or page title will be used.

#### Usage Examples

**Simple link (standard form):**

> `<a href="[permalink wpid='123']">link text</a>`

_Result:_

> `<a href="http://www.example.com/hello-world/">link text</a>`

**Simple link (enclosing form):**

> `[permalink wpid="123"]link text[/permalink]`

_Result:_

> `<a href="http://www.example.com/hello-world/" class="permalink-shortcode" title
> ="Hello, world!">link text</a>`

**Linking to the Comments section of a post (standard form):**

> `<a href="[permalink wpid='123']#comments">link text</a>`
> …or…
> `<a href="[permalink wpid='123' fragment='comments']">link text</a>`

_Result:_

> `<a href="http://www.example.com/hello-world/#comments">link text</a>`

**Adding a custom CSS class and title (enclosing form):**

> `[permalink wpid="123" class="my-class" title="Some Other Page"]link text[/permalink]`

_Result:_

> `<a href="http://www.example.com/hello-world/" class="permalink-shortcode my-class"
> title="Some Other Page">link text</a>`

## 安装

 1. Unzip the downloaded .zip file.
 2. Upload the `permalink-shortcode` folder to your `/wp-content/plugins/` directory.
 3. Activate the plugin through the ‘Plugins’ menu in WordPress

## 常见问题

  How do I find the ID of the post or page?

The ID for a post or page can be found in just about any Edit link for that content.
All you need to do is hover your mouse over the link and look at the tooltip that
displays the URL (where this appears depends on the browser you’re using). An example:

> `http://www.example.com/wp-admin/post.php?post=123&action=edit`

In the above example, `123` is the ID of the post. This is the number you want to
use for the shortcode’s `wpid` attribute, like so:

> `[permalink wpid="123"]`

## 评价

![](https://secure.gravatar.com/avatar/87c5626d0cfdf5349ac80254477e9c87fde5150bc66e1952351aaafe778eea41?
s=60&d=retro&r=g)

### 󠀁[Still excellent](https://wordpress.org/support/topic/still-excellent-2/)󠁿

 [mindwarp2000](https://profiles.wordpress.org/mindwarp2000/) 2018 年 4 月 10 日

Taken me half an hour to find this gem. I can add links to drafts too. If only it
worked with media too.

![](https://secure.gravatar.com/avatar/59adb44a65c7e2858c35031494c27ab63d48cceaa59e018818b330027b6619cd?
s=60&d=retro&r=g)

### 󠀁[Can’t find how to setup](https://wordpress.org/support/topic/cant-find-how-to-setup/)󠁿

 [alfredovazquez](https://profiles.wordpress.org/avazquezsicrom/) 2018 年 3 月 21
日 1 回复

¿where is the menu to setting up?

 [ 阅读所有4条评价 ](https://wordpress.org/support/plugin/permalink-shortcode/reviews/)

## 贡献者及开发者

「Permalink Shortcode」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ Ryan ](https://profiles.wordpress.org/rlange/)

[帮助将「Permalink Shortcode」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/permalink-shortcode)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/permalink-shortcode/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/permalink-shortcode/)，或通过[RSS](https://plugins.trac.wordpress.org/log/permalink-shortcode/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/permalink-shortcode/)。

## 更新日志

#### 1.0.0

 * Initial release.

## 额外信息

 *  版本 **1.0.0**
 *  最后更新：**13 年前**
 *  活跃安装数量 **100+**
 *  WordPress 版本 ** 2.8 或更高版本 **
 *  已测试的最高版本为 **3.5.2**
 *  语言
 * [English (US)](https://wordpress.org/plugins/permalink-shortcode/)
 * 标签
 * [permalink](https://cn.wordpress.org/plugins/tags/permalink/)[shortcode](https://cn.wordpress.org/plugins/tags/shortcode/)
 *  [高级视图](https://cn.wordpress.org/plugins/permalink-shortcode/advanced/)

## 评级

 4 星（最高 5 星）。

 *  [  3 条 5 星评价     ](https://wordpress.org/support/plugin/permalink-shortcode/reviews/?filter=5)
 *  [  0 条 4 星评价     ](https://wordpress.org/support/plugin/permalink-shortcode/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/permalink-shortcode/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/permalink-shortcode/reviews/?filter=2)
 *  [  1 条 1 星评价     ](https://wordpress.org/support/plugin/permalink-shortcode/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/permalink-shortcode/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/permalink-shortcode/reviews/)

## 贡献者

 *   [ Ryan ](https://profiles.wordpress.org/rlange/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/permalink-shortcode/)