wordpress模板标签previous post(s) link

作者:  耕堂 | 本文浏览584次 | 2009年09月2日

该标签在wordpress中和next post(s) link的功能正好相反,顾名思义,previous和next,很显然是前面的文章链接,但不能完全按字面理解。
1.previous post link
-description:
用在single页, 显示当前文章前(按发布时间)的文章标题。须在循环loop内使用。
-how to use:

<?php previous_post_link(‘format’, ‘link’, in_same_cat,
‘excluded_categories’); ?>

-argument-introduce:

  • foremat
  • (字符串)链接字符串格式。’%link’的结果可参考下面例子。默认为’%link »’。

  • link
  • (字符串)链接文本 。默认为’%title’(显示为next post title)。

  • in_same_cat
  • (布尔)指明上一篇文章与当前文章是否属同一分类。TRUE -是;FALSE -否(default)。

  • excluded_categories
  • (字符串)指定排除某分类的文章。如1and5and15,id要以and间隔。

    -using examples:
    1.default use。

    <?php previous_post_link(); ?>

    效果:《”文章标题”

    2.加粗显示文章标题。

    <?php previous_post_link(‘<strong>%link</strong>’); ?>

    3.自定义链接文本而不直接显示文章标题,且与当前文章同分类。

    <?php previous_post_link(‘%link’, ‘Previous in category’, TRUE); ?>

    效果:Previous in category

    4.在上面例3的基础上排除id为13的分类。

    <?php previous_post_link(‘%link’, ‘Previous in category’, TRUE, ‘13′); ?>

    效果:Previous in category

    这里有英文文档

    2.previous posts link
    -tag description:
    显示后面文章的链接。注意它依据文章发布时间的逆顺序显示链接。
    -how to use:

    <?php previous_posts_link( $label , $max_pages ); ?>

    -argument introduce:

  • $label
  • (字符串)(可选)锚文本。默认为’《Previous Page ‘。

  • $max_pages
  • (整数)(可选)显示的页面数。默认为0。

    -using examples:
    1.default use。

    <?php previous_posts_link(); ?>

    2.链接文本自定义。

    <?php previous_posts_link(‘? Newer Entries’, ‘0′) ?>

    参考英文文档

     右上方更多相关内容/站内搜索-关键词请用空格隔开

  • 标签 :  ,
  • 原文链接 : http://www.gengtang.net/wordpress/previous-posts-link.html
  • 转载原创文章请注明 : 耕堂-gengtang.net
  •  “wordpress模板标签previous post(s) link” 有2条评论

    1. 2010年2月10日的5:12 下午,传说中的 Lee:

      请教个问题这个函数的第三个参数设为true意思就是显示当前文章的同分类,但是如果我在后台发表的文章一个sport主分类下有basketball,football子分类,然后这两个子分类下的文章会算是当前文章的同分类吗?

    2. 2010年2月11日的12:16 下午,传说中的 耕堂

      回复# Lee
      应该是的,这些文章都属于sport下。如果想通过这个函数区分子分类,可能不行,你可以自己试试确认一下

    发表留言

    可用HTML标签:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>