分享一个比较少用大但是比较使用的wordpress文章内页分页函数wp_link_pages() 不是普通的文章的分页哦。



WordPress自身带有文章分页功能,可能该功能不被博主们常用,在默认的TinyMCE编辑器下给隐匿了。你可以尝试编辑文章时在HTML视图下插入短码<!–nextpage–>,看看你的主题有没有分页效果,没有也没关系,看了本文就知道了。WordPress v5.8.1官方正式版及必备优化代码

Share a relatively small but relatively used WordPress article page paging function wp_link_pages() is not an ordinary article paging.

Article page paging function: wp_link_pages(), through in-depth understanding of this function, we will complete the paging of article pages.

For a relatively long article, single-page reading is no longer suitable for her. It will not only make visitors feel uncomfortable, but it is also very unfriendly to the layout of our article pages. At this time, we urgently need to paginate articles, but the default pagination of WordPress cannot satisfy us.

It has an article paging function, which may not be commonly used by bloggers and is hidden under the default TinyMCE editor. You can try to insert the shortcode <!–nextpage–> in the HTML view when editing the article to see if your theme has a paging effect. It doesn’t matter if you don’t, you’ll know after reading this article.

Article paging function description Array function description: before paging navigation, you can write text, you can set the style of paging navigation to close the next page or page number next page link previous page link page number link , The specific style is not explained, DIY by yourself. Choose to use according to your needs, find the following code in the theme single.php, and paste the article pagination form of your choice below the code here.

When editing an article, insert the following article paging segment code in the HTML view to achieve article paging.

Form 1: Description: The page number loads the style of page-links through before and after Form 2: Previous page Next page Previous page&nextpagelink=Next page Description: Turn pages through the upper and lower pages, the style is bold Form 3: Previous page 1 2 3 I revised the following code on the next page and added a judgment sentence to solve the problem of code occupancy when the article is not paged. The above two groups have not been modified, please modify according to the following code.

PrevNext’);} ?>Description: Up and down pages are turned in bold, and the page number is loaded with wp-pagenavi style. Follow-up: Incomplete feed output After using article paging, there will be a problem, that is, incomplete feed output, only output The first page of the article page, this will affect the reading of the rss subscribers. The solution is as follows: Find “query.php” in the “wp-includes” directory, and find the following sentence: Modify it to: More WordPress article paging related articles can be viewed: How to realize article paging without plugins How to article paging Title add page number paging page_WordPress article paging function (wp_link_pages article digital paging and page up and down)

If an article is paginated, it will greatly reduce the quick reading experience. WordPress also supports the pagination function of article content, but the wp_link_pages function it provides is a bit unfriendly.

This function provides a paging mode, which is either page up and down or digital paging. What if you want to have both up and down page and digital paging?

Put the following code in the functions.php file of the current theme: The calling method is as follows: previous page’,’nextpagelink’ => “nextpagelink”)); for the sake of beauty, you can also simply write a css style, below It is a very simple style of Zifan: If you find that your WordPress theme article or page content does not support paging, you can call it directly in this way. Of course, if you don’t need to have both digital paging and up and down pages at the same time , Then use the wp_link_pages function directly, and fill in next or number in the’next_or_number’ field!



<?php wp_link_pages( $args ); ?>


<?php $args = array(
‘before’ => ‘<p>’ . __(‘Pages:’),//分页导航前,可写文字,可设置样式
‘after’ => ‘</p>’,//分页导航闭合
‘link_before’ => ,
‘link_after’ => ,
‘next_or_number’ => ‘number’,//下一页还是页码
‘nextpagelink’ => __(‘Next page’),//下一页链接
‘previouspagelink’ => __(‘Previous page’),//上一页链接
‘pagelink’ => ‘%’,//页码链接
‘more_file’ => ,
‘echo‘ => 1 ); ?>



<?php the_content(); ?>



形式一:page 1 2 3

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


形式二:上一页 下一页

<?php wp_link_pages(‘before=<strong>&after=</strong>&next_or_number=next&previouspagelink=上一页&nextpagelink=下一页’); ?>


形式三:上一页 1 2 3 下一页


<?php if ( $numpages > ‘1’ ) {
wp_link_pages(‘before=<span class=“wp-pagenavi”>&after=</span>&next_or_number=number’);
echo “&nbsp;”;
} ?>




if ( strpos( $content, ‘<!–nextpage–>’ ) ) {

if ( strpos( $content, ‘<!–nextpage–>’ ) && ( !is_feed() ) ) {







一篇文章如果被分页,将会大大的降低了快速阅读的体验,WordPress 也是支持文章内容的分页功能,但是其提供的 wp_link_pages 函数却有点不友好。

WordPress wp_link_pages 这个函数提供了分页模式,要么是上下翻页,要么就是数字分页,如果想要既有上下翻页,又有数字分页该怎么办呢?

将以下代码放在当前主题的 functions.php 文件中:

‘,’after’ => ‘
‘,’next_or_number’ => ‘next_and_number’, ‘link_before’ => ”,’link_after’ => ”,’previouspagelink’ => ‘上一页’,’nextpagelink’ => “下一页”));

为了美观,大家还可以简单的写个 css 样式,下面是子凡的一个非常简单的样式:

如果你发现你的 WordPress 主题文章或者页面内容不支持分页,那么可以通过这样的一个方式方法直接调用啦,当然如果你不需要同时拥有数字分页和上下翻页,那么直接使用 wp_link_pages 函数,’next_or_number’字段填写 next 或 number 就可以啦!