WordPress文章单页面 分页函数php wp_link_pages详解

WordPress文章单页面 分页函数<?php wp_link_pages(); ?>详解 WordPress分页函数详解

另有 WordPress文章分页wp_link_pages()函数详解

一、子页面函数(单篇文章分页)

函数一:wp_link_pages

功能说明
如果一篇文章中包括几处《 !–nextpage–》 标签,就会将这篇文章分成若干页,并显示文章子页面的链接。

用法:

<?php wp_link_pages(‘参数’); ?>

示例
默认用法:

<?php wp_link_pages(); ?>

显示为:
Pages:1 2 3

显示一长串子页面的链接列表:

<?php wp_link_pages(‘before=<p>&after=</p>&next_or_number=number&pagelink=page %’); ?>
<?php wp_link_pages(‘before=’<p>本文导航:’&after=’</p>’&nextpagelink=’<strong>继续下一页</strong>’&previouspagelink=’<strong>返回上一页</strong>&next_or_number=unmber’); ?>

显示为:
page 1 page 2 page 3
对子页面的链接装入DIV(id=page-links)引用 CSS

<?php wp_link_pages(‘before=<div id=”page-links”>&after=</div>’); ?>

详细参数说明
before (字符串)所有链接前面显示的文字,默认为

Pages
after (字符串)所有链接后面显示的文字,默认为

link_before (字符串)链接前面显示的文字,默认为空,只在wordpress版本为2.7以上才有效
link_after (字符串)链接后面显示的文字,默认为空,只在wordpress版本为2.7以上才有效
next_or_number (字符串)是否显示子页面序号所显示的格式,l默认参数number,即显示(不显示页面序号参数为next,next参数只在Wordpress 1.5以上版本有效)。
nextpagelink (字符串)下一子页面的链接所显示的文字,默认为Next page(只在WordPress 1.5及以上有效)
previouspagelink(字符串)返回上一子页面的链接所显示的文字,默认为Previous page(只在WordPress 1.5及以上有效)
pagelink (字符串)子页面序号的格式,默认参数为%,%这个字符表示子页面数字序号,例如Page %会生成”Page 1″, “Page 2″等链接和文字。
more_file (字符串)指向当前子页面的文字

函数二:link_pages(即将失效)
说明:功能和wp_link_pages一样。已经被wp_link_pages取代,前段时间测试Wordpress2.6调用正常,不过在后续的版本中可能会被停用,故不做特别说明。

 

上面是最常用的

下面是没用过的 参考资料 blog.csdn.net/dengwenquan2011/article/details/6858297

Detailed explanation of WordPress pagination function 1. Sub-page function (single article pagination)
Function 1: wp_link_pages function description If an article includes several “!–nextpage–” tags, the article will be divided into several pages, and links to the article’s subpages will be displayed.
Usage: <?php wp_link_pages(‘parameter’); ?> Example default usage: <?php wp_link_pages(); ?> Displayed as: Pages:1 2 3 Display a list of links to a long list of subpages: <?php wp_link_pages(‘ before=<p>&after=</p>&next_or_number=number&pagelink=page %’); ?><?php wp_link_pages(‘before='<p>This article navigation:’&after='</p>’&nextpagelink='< strong>Continue to the next page</strong>’&previouspagelink='<strong>Return to the previous page</strong>&next_or_number=unmber’); ?>Displayed as: page 1 page 2 page 3 Load DIV for the link of the subpage (Id=page-links) Quote CSS<?php wp_link_pages(‘before=<div id=”page-links”>&after=</div>’); ?> Detailed parameter description before (string) All links are displayed before The default is Pagesafter (string) the text displayed after all links, the default is link_before (string) the text displayed before the link, the default is empty, only valid if the wordpress version is 2.7 or higher link_after (string) after the link The displayed text, which is empty by default, is only valid when the wordpress version is 2.7 or higher. Next_or_number (string) Whether to display the format displayed by the sub-page serial number, l The default parameter number, that is, display (the page serial number parameter is next, next parameter is not displayed) Only valid in WordPress 1.5 and above).
Nextpagelink (string) The text displayed on the link of the next subpage, the default is Next page (only valid in WordPress 1.5 and above)
Previouspagelink (string) returns the text displayed in the link of the previous subpage, the default is Previous page (only valid in WordPress 1.5 and above)
Pagelink (string) The format of the subpage serial number. The default parameter is %. This character represents the numerical serial number of the subpage. For example, Page% will generate links and texts such as “Page 1” and “Page 2″.
More_file (string) point to the current subpage text function two: link_pages (will be invalid soon)
Description: The function is the same as wp_link_pages. It has been replaced by wp_link_pages. It was tested that WordPress2.6 is called normally some time ago, but it may be disabled in subsequent versions, so no special instructions are given.
The above is the most commonly used and the following is the unused reference material blog.csdn.net/dengwenquan2011/article/details/6858297 2. Paging function (multiple article paging) posts_nav_link function description in the main page, directory page, The archive page displays links to turn pages, such as page numbers, links to previous and next pages.
In particular, if you want to display the previous and next post links on a separate post page, please use the next_post_link and previous_post_link functions. Usage: <?php posts_nav_link(‘sep’,’prelabel’,’nxtlabel’); ?> Example default usage: <?php posts_nav_link(); ?> will display the following, «Previous Page — Next Page» Example 2: <div style=”text-align:center;”><?php posts_nav_link(‘ · ‘ ,’previous page’,’next page’); ?></div> Shows the previous page · next page and is located in the center of the page.
Example 3: <?php posts_nav_link(”,'<img src=”images/prev.jpg” />’,'<img src=”images/next.jpg” />’); ?> show two small Icon, the icon points to the link of the previous post and the next post respectively.
Example 4: <?php posts_nav_link(‘ or’,’You can go backto the previous page’,’you can goforward to the next page’); ?>Customize the text displayed by the link and the characters before the link, the code above It will be displayed as You can go back to the previous page or you can go forward to the next page. Detailed parameter description sep (string) the character before the link prelabel (string) the text displayed in the previous log link nxtlabel (character String) The text displayed by the link of the next post. 3. The More tag function the_excerpt “!—more–” tag is a very useful feature of WordPress. It allows you to select the cut-off point, and then only the text before the cut-off point is displayed on the homepage.
But the function of the log we need to display is similar to <?php the_excerpt(__(‘Read more’));?>, where “Read more” can be replaced with the text you want, and we are also simple when it comes to this Mention the difference between the_content and the_excerpt. The truncated content displayed by the_content function is manually added in the abstract part of the log page in the background, while the_excerpt can automatically identify the more tag in the article, but the_content function can display more information. For example, pictures, tables, etc., and the_excerpt can only truncate the text content and ignore the format of the text. As for how to choose, it depends on personal hobbies.

 

以上就是 WordPress文章单页面 分页函数<?php wp_link_pages(); ?>详解全部内容

二、分页函数(多篇文章分页)posts_nav_link 请看第二页

点此翻页下一页

发表评论

后才能评论