康爷的博客

关于康爷的日志,IT相关,火鸟,Live Space教程,和iPhone的最新报道和数学相关的内容



feedsky

Wordpress插件Simple Tags的技术文档

函数调用篇:

Related Posts : st_related_posts()

With this functionnality, you can show related posts on your post. Is related posts which have at least one common tag.
If you don't wish to show related posts, but use them inside the loop, use st_get_related_posts() function.

Usage:
  1. <?php st_related_posts(); ?>

Default Usage:
  1. 'number' => 5,

  2. 'order' => 'count-desc',

  3. 'format' => 'list',

  4. 'include_page' => 'true',

  5. 'exclude_posts' => '',

  6. 'exclude_tags' => '',

  7. 'post_id' => '',

  8. 'except_wrap' => '55',

  9. 'limit_days' => '0',

  10. 'title' => __('<h4>Related posts</h4>', 'simpletags'),

  11. 'nopoststext' => __('No related posts.', 'simpletags'),

  12. 'dateformat' => $this->dateformat,

  13. 'xformat' => __('<a href="%post_permalink%" title="%post_title% (%post_date%)">%post_title%</a> (%post_comment%)', 'simpletags')

Example:

We want to show the first 10 related post without title, without pages and without comments count.

  1. <?php st_related_posts('number=10&title=&include_page=false&xformat=<a href="%permalink%" title="%title% (%date%)">%title%</a>'); ?>

Parameters:
  • number
    (integer) Number of posts to show
  • order
    (string) Order posts sorting. Valid values are :
    • count-desc - (default) by number of common tags (most relevance)
    • count-asc - by number of common tags (less relevance)
    • date-desc - by publication's date descending
    • date-asc - by publication's date ascending
    • name-asc - by title ascending
    • name-desc - by title descending
    • random - random
  • format
    (string) show tags as non ordered list UL/LI
    • flat - (Default) posts are separated with spaces
    • list - posts are inside non ordered lists containing class='related_posts'
    • array -posts are inside a PHP array (use it with st_get_related_posts())
  • include_page
    (boolean) "true" to add pages, "false" only for posts
  • exclude_posts
    (string) Separate posts ID to exclude with commas
  • exclude_tags
    (string) Separate tags ID to exclude with commas
  • post_id
    (integer) Specified post ID for display related posts
  • except_wrap
    (integer) Words number for excerpt.
  • limit_days
    (string) Limit result with a max days
  • title
    (string) Specify the positioned title before the list
  • nopoststext
    (string) Specify the text to show when there is no related post
  • dateformat
    (string) Specify the date format. Same format as
    PHP date function
  • xformat
    (string) Extended links format. Available Markups :
    • %post_date% - Replaced by the date of the post
    • %post_permalink% - Replaced by the permalink of the link
    • %post_title% - Replaced by the title of the post
    • %post_comment% - Replaced by the comments count of the post
    • %post_tagcount% - Replaced by the number of common tags
    • %post_id% - Replaced by the ID of the post
    • %post_relatedtags% - Replaced by common tag list
    • %post_excerpt% - Replaced by post excerpt
Tags cloud: st_tag_cloud()

With this functionnality you can show a color tags cloud created dynamically.
If you don't want to show it, but use it, use st_get_tag_cloud() function.

Usage:
  1. <?php st_tag_cloud(); ?>

Default Usage:
  1. 'size' => 'true',

  2. 'smallest' => 8,

  3. 'largest' => 22,

  4. 'unit' => 'pt',

  5. 'color' => 'true',

  6. 'maxcolor' => '#000000',

  7. 'mincolor' => '#CCCCCC',

  8. 'number' => 45,

  9. 'format' => 'flat',

  10. 'cloud_selection' => 'count-desc',

  11. 'cloud_sort' => 'random',

  12. 'exclude' => '',

  13. 'include' => '',

  14. 'limit_days' => 0,

  15. 'min_usage' => 0,

  16. 'notagstext' => __('No tags.', 'simpletags'),

  17. 'xformat' => __('<a href="%tag_link%" class="tag-link-%tag_id%" title="%tag_count% topics" %tag_rel% style="%tag_size% %tag_color%">%tag_name%</a>', 'simpletags'),

  18. 'title' => __('<h4>Tag Cloud</h4>', 'simpletags'),

  19. 'category' => 0

Example:

We wish to display randomly the top 100 tags, the max width will be 45px, the min 12px. The color used for max tags will be red (#FF0000) and for min tags green (#00FF0B). At last, the title will be "Tags Cloud"

  1. <?php st_tag_cloud('cloud_selection=count-desc&cloud_sort=random&number=100&title=Mon nuage de tags&largest=45&smallest=12&unit=px&maxcolor=#FF0000&mincolor=#00FF0B'); ?>

Parameters:
  • size
    (boolean) Active or not dynamic font size generation
  • smallest
    (integer) Length of the font to use to show the less used tags
  • largest
    (integer) Length of the font to use to show the most used tags
  • unit
    (string) Measuring unit of the used font for smallest and largest parameters. Use pt for point
  • color
    (boolean) Active or not dynamic color generation. true/false
  • maxcolor
    (string) Used color for most popular tags
  • mincolor
    (string) Used color for less popular tags
  • number
    (integer) Number of tags to show inside the tags cloud (Use '0' to show all of them)
  • format
    (string) Tag's format of posting
    • flat - (Default) Tags are separated by spaces
    • list - tags are inside a non ordered list (UL) containing class='st-tag-cloud'
    • array - tags are inside a PHP array (use it with st_get_tag_cloud())
  • cloud_selection
    (string) Tags selection order. Valid values are :
    • count-desc - (default) by number of usage tags (most popular)
    • count-asc - by number of usage tags (least used)
    • name-asc - by tag name ascending
    • name-desc - by tag name descending
    • random - random
  • cloud_sort
    (string) Tags selection order. Valid values are :
    • count-desc - by number of usage tags (most popular)
    • count-asc - by number of usage tags (least used)
    • name-asc - by tag name ascending
    • name-desc - by tag name descending
    • random - (default) random
  • exclude
    (string) list of tags to exclude, separated by commas (term_id). For example 'exclude=5,27' means all tags which contain term_id 5 or 27 will be NOT shown. By default, any tag is excluded.
  • include
    (string) list of tags to include, separated by commas (term_id). For example 'exclude=5,27' means all tags which contain term_id 5 or 27 will be the alone tags to be shown. By default, all tags are included
  • limit_days
    (integer) Number of days to be considered to generated tag cloud.
  • min_usage
    (integer) Min number of tag counter for display it into tag cloud
  • notagstext
    (string) Text to show, if there is no tag.
  • xformat
    (string) Extended format of links. You can personalize the formating of tag's link. Available markups :
    • %tag_link% - Replaced by the permalink of the tag
    • %tag_feed% - Replaced by the RSS tag link
    • %tag_id% - Replaced by the tag ID
    • %tag_count% - Replaced by the use number (counter) of the tag
    • %tag_size% - Replaced by the size of the tag (creates : font-size:17pt;)
    • %tag_color% - Replaced by the color of the tag (creates : color:#666666;)
    • %tag_name% - Replaced by the tag's name
    • %tag_name_attribute% - Replaced by the tag's name, formatted for attribute HTML
    • %tag_rel% - Replaced by rel tag markup (creates : rel="tag")
    • %tag_scale% - Replaced by tag scale (between 1 and 10)
    • %tag_technorati% - Replaced by Technorati tag link
    • %tag_flickr% - Replaced by Flickr tag link
    • %tag_delicious% - Replaced by Del.ici.ous tag link
  • title
    (string) Specify the positioned title shown before tags cloud
  • category
    (string) Restrict tag cloud to a specifik category. (or more, separated with comma)
Current posts tags: st_the_tags()

This feature extend WordPress builtin function "the_tags()", you can specify tag format, text if no tags and post id, also outside the loop
If you don't want to show it, but use it, use st_get_the_tags() function.

Usage:
  1. <?php st_the_tags(); ?>

Default Usage:
  1. 'before' => __('Tags: ', 'simpletags'),

  2. 'separator' => ', ',

  3. 'after' => '

  4. ',

  5. 'post_id' => '',

  6. 'xformat' => __('<a href="%tag_link%" title="%tag_name%" %tag_rel%>%tag_name%</a>', 'simpletags'),

  7. 'notagtext' => __('No tag for this post.', 'simpletags'),

  8. 'number' => 0

Parameters:
  • before
    (string) Text to display before the actual tags are displayed. Defaults to Tags:
  • separator
    (string) Text or character to display between each tag link. The default is a comma (,) between each tag.
  • after
    (string) Text to display after the last tag. The default is to display nothing.
  • post_id
    (integer) Specified post ID for display tag posts (outside loop by example)
  • xformat
    string) Extended format of links. You can personalize the formating of tag's link. Available markups :
    • %tag_link% - Replaced by the permalink of the tag
    • %tag_feed% - Replaced by the RSS tag link
    • %tag_id% - Replaced by the tag ID
    • %tag_name% - Replaced by the tag's name
    • %tag_name_attribute% - Replaced by the tag's name, formatted for attribute HTML
    • %tag_rel% - Replaced by rel tag markup (creates : rel="tag")
    • %tag_technorati% - Replaced by Technorati tag link
    • %tag_flickr% - Replaced by Flickr tag link
    • %tag_delicious% - Replaced by Del.ici.ous tag link
  • notagtext
    (string) Text to show, if there is no tag.
  • number
    (integer) Limit tags output with this max number
Related tags: st_related_tags()

This feature display a list of related tags into tag view. It allow to restrict tag search with an another tag.
This function output a list only on tag view, else it display nothing.

If you don't wish to show related tags, but use them inside the loop, use st_get_related_tags() function.

Usage:
  1. <?php st_related_tags(); ?>

Default Usage:
  1. 'number' => 5,

  2. 'order' => 'count-desc',

  3. 'separator' => ' ',

  4. 'format' => 'list',

  5. 'method' => 'OR',

  6. 'title' => __('<h4>Related tags</h4>', 'simpletags'),

  7. 'notagstext' => __('No related tag found.', 'simpletags'),

  8. 'xformat' => __('<span>%tag_count%</span> <a href="%tag_link_add%">+</a> <a href="%tag_link%">%tag_name%</a>', 'simpletags')

Parameters:
  • number
    (integer) Number of posts to show
  • order
    (string) Order posts sorting. Valid values are :
    • count-desc - (default) by tag counter (most popular)
    • count-asc - by tag counter (less used)
    • name-asc - by tag name ascending
    • name-desc - by tag name descending
    • random - random
  • format
    (string) output format
    • flat - (Default) tags are separated with spaces
    • list - tags are inside non ordered lists containing class='related_posts'
    • array - tags are inside a PHP array (use it with st_get_related_posts())
  • method
    (string) Method of tags intersections and unions used to build related tags link:
    • OR - Fetches posts with either the "Tag1" or the "Tag2" tag.
    • AND - Fetches posts with both the "Tag1" and the "Tag2" tag.
  • title
    (string) Specify the positioned title before the list
  • notagstext
    (string) Specify the text to show when there is no related tags
  • xformat
    (string) Extended links format. Available Markups :
    • %tag_link_add% - Replace by the link, build from the actual URL + Tag to add
    • %tag_link% - Replaced by the permalink of the tag
    • %tag_feed% - Replaced by the RSS tag link
    • %tag_id% - Replaced by the tag ID
    • %tag_count% - Replaced by the use number (counter) of the tag
    • %tag_name% - Replaced by the tag's name
    • %tag_name_attribute% - Replaced by the tag's name, formatted for attribute HTML
    • %tag_rel% - Replaced by rel tag markup (creates : rel="tag")
    • %tag_technorati% - Replaced by Technorati tag link
    • %tag_flickr% - Replaced by Flickr tag link
    • %tag_delicious% - Replaced by Del.ici.ous tag link
    Remove related tags: st_remove_related_tags()

    This feature display a list of remove related tags into tag view. It allow to remove one tag from URL.
    This function output a list only on tag view, else it display nothing.

    If you don't wish to show remove related tags, but use them inside the loop, use st_get_remove_related_tags() function.

    Usage:
    1. <?php st_remove_related_tags(); ?>

    Default Usage:
    1. 'separator' => ' ',

    2. 'format' => 'list',

    3. 'notagstext' => ' ',

    4. 'xformat' => __('&raquo; <a href="%tag_link_remove%" title="Remove %tag_name_attribute% from search">Remove %tag_name%</a>', 'simpletags')

    Parameters:
    • format
      (string) output format
      • flat - (Default) tags are separated with spaces
      • list - tags are inside non ordered lists containing class='related_posts'
      • array - tags are inside a PHP array (use it with st_get_related_posts())
    • notagstext
      (string) Specify the text to show when there is no related tags
    • xformat
      (string) Extended links format. Available Markups :
      • %tag_link_remove% - Replaced by the link with current tags except tags to remove
      • %tag_link% - Replaced by the permalink of the tag
      • %tag_feed% - Replaced by the RSS tag link
      • %tag_id% - Replaced by the tag ID
      • %tag_count% - Replaced by the use number (counter) of the tag
      • %tag_name% - Replaced by the tag's name
      • %tag_name_attribute% - Replaced by the tag's name, formatted for attribute HTML
      • %tag_rel% - Replaced by rel tag markup (creates : rel="tag")
      • %tag_technorati% - Replaced by Technorati tag link
      • %tag_flickr% - Replaced by Flickr tag link
      • %tag_delicious% - Replaced by Del.ici.ous tag link
原文地址:Wordpress插件Simple Tags的技术文档 (转载请注明)

blogmarks del.icio.us Google Live MisterWong Reddit Technorati TwitThis

相关文章

2 comments for this post.

  1. Comment from cnpabi on 07月 14th, 2008 :

    分享了,呵呵

    [ 引用 ]

    [回复]

  2. Comment from 深圳瑜伽 on 10月 4th, 2008 :

    很好!谢谢分享!

    [ 引用 ]

    [回复]

想说点什么吗?