內容簡介
從 WordPress 3.0 開始,此外掛的大部分原始功能已經納入 WordPress 中。WordPress 會預設在大多數頁面上增加短網址。此外掛僅添加一個設定頁面,讓您可以輕鬆進行一些微小的調整。
WordPress 短網址非常適合微型博客使用,您可以使用自己的網域而不是第三方短網址服務。
URL 會自動添加到每篇文章、頁面、附件和類別的 HTTP 和 HTML 首標,
使用模板標籤可以顯示人類可讀的連結,除了自動生成的表頭外。強烈推薦使用人類可讀的連結,因為 Google 會優先考慮該連結並將其排名高於某些較長的 URL。這樣可以提高被 Google 認定為“太長”的 URL 的排名。此外,在許多行動 Web 瀏覽器中,訪問者最容易找到短網址的方式就是在頁面的某個位置看到它。
通過為打印媒體添加 CSS 代碼,可以進一步擴展模板標籤的功能,這可以確保每篇文章的短鏈接 URL 與文章一起打印。這會使用戶在閱讀硬拷貝後更容易返回文章。
主題
關於 Simple Short Links 提供的模板功能,目前的文檔應該在 函數參考/短鏈接中 找到。
這裡是 Simple Short Links 提供的模板功能的基本參考。 WordPress 3.0+ 用戶,請參閱 wp-includes/link-template.php 以了解更多有關 the_shortlink() 的詳細信息。
/**
* 用於顯示短鏈接的模板標籤
*
* 必須在"The Loop"中調用
*
* 如下面示例調用: <?php the_shortlink(__('Shortlinkage FTW')); ?>
*
* @since 1.1
* @param string $text Optional 要顯示的連結文字或 HTML。預設為 'This is the short link.'。
* @param string $title Optional 連結提示文本。必須被消毒過。預設為已消毒的文章標題。
*/
function the_shortlink($text = '', $title = '');
第二個類似的標籤現在可用,以便在類別頁面上顯示自我引用的短鏈接。
/**
* 用於顯示類別的短鏈接的模板標籤
*
* 應在"The Loop"之外調用。
*
* 如使用下面示例調用: <? the_single_shortlink(__('Shortlinkage FTW')); ?>
*
* @since 1.3
* @param string $text Optional 要顯示的連結文字或 HTML。預設為 'This is the short link.'。
* @param string $title Optional 連結提示文本。必須被消毒過。預設為已消毒的類別名稱。
*/
function the_single_shortlink($text = '', $title = '');
CSS 打印技巧
試著在您的主題 CSS 檔添加像這樣的內容,以便在列印時顯示短鏈接的 URL。
@media print {
.shortlink a:link:after {
content: " " attr(href);
}
}
CSS 示例假定 the_shortlink() 在具有“shortlink”類屬性的 DIV 或 P 元素中使用。
外掛標籤
開發者團隊
原文外掛簡介
As of WordPress 3.0, most of this plugin’s original features have been incorporated into WordPress itself. WordPress adds shortlinks to most pages by default. This plugin simply adds a settings page where you can easily make some minor adjustments.
WordPress shortlinks are useful for micro-blogging, by using your own domain instead of a 3rd-party short URL service.
The URLs are automatically added to the HTTP and HTML headers of each post, page, attachment, and category.
A template tag enables you to display a human-readable link in addition to the automatically generated headers. Use of human-readable links is highly encouraged, because Google is known to favor them and rank them higher than some longer URLs. This has the effect of boosting the rank of URLs that were deemed “too long” by Google’s standards. Also, in many mobile web browsers, the easiest way for a visitor to find a short link is by seeing it somewhere on the page.
The template tag idea can be extended further with CSS code for print media, which could ensure that each article’s short link URL is printed along with the article. This will make it much easier for the user to return to the article after reading a hard copy.
Theme
Current documentation should be found at Function Reference/the shortlink
Here is a basic reference for the template functions provided by Simple Short Links. WordPress 3.0+ users, see also wp-includes/link-template.php for more details about the_shortlink().
/**
* Template Tag for Displaying the Short Link
*
* Must be called from inside "The Loop"
*
* Call like
*
* @since 1.1
* @param string $text Optional The link text or HTML to be displayed. Defaults to 'This is the short link.'
* @param string $title Optional The tooltip for the link. Must be sanitized. Defaults to the sanitized post title.
*/
function the_shortlink($text = '', $title = '');
A second, similar tag is now available in case you need to display a self-referring short link on a category page.
/**
* Template Tag for Displaying the Short Link for a Category
*
* Should be called from outside "The Loop"
*
* Call like the_single_shortlink(__('Shortlinkage FTW')); ?>
*
* @since 1.3
* @param string $text Optional The link text or HTML to be displayed. Defaults to 'This is the short link.'
* @param string $title Optional The tooltip for the link. Must be sanitized. Defaults to the sanitized category name.
*/
function the_single_shortlink($text = '', $title = '');
The CSS Printing Trick
Try adding something like this to your theme’s CSS file to make the URL for the short link appear when printed.
@media print {
.shortlink a:link:after {
content: " " attr(href);
}
}
The CSS example assumes the_shortlink() is used inside of a DIV or P element with a class attribute called “shortlink”.
