上一篇文章、下一篇文章

previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' );
next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' );

看函数名称知道,这两个方法都是生成一个链接。format 指的是链接格式,link指的是链接显示的文本,in_same_term 表示是否与当前文章在同一分类下, excluded_terms 表示排队在外的分类,taxonomy 是基于in_same_term的。

前后结合

the_post_navigation( array(
'prev_text' => __( '上一篇: %title' ),
'next_text' => __( '下一篇: %title' ),
'screen_reader_text' => ( '自定义标题' )
));

上一页、下一页

<?php
previous_posts_link( $label = null );
next_posts_link( $label = null, $max_page = 0 );
?>

你会发现上一页、下一页 方法名与 上一篇文章、下一篇文章只是一个s字母的差别,而参数更简洁了,可自定义的内容更少了些。当然这里不能叫next_page_link,因为page是页面的意思,不是分页的意思。文章按发布时间有新旧之分,前一页呢是看较新的文章,后一页呢是较早前文章,而max_page这个参数是指定你可以看多旧,所以,上一页没有这个参数。

文章分页导航 the_posts_pagination

参数

  • mid_size (int) - How many page numbers to display to either side of the current page. Defaults to 1.
  • prev_text (string) - Text of the link to the next set of posts. Defaults to “Previous”.
  • next_text (string) - Text of the link to the next set of posts. Defaults to “Next”.
  • screen_reader_text (string) - Text meant for screen readers. Defaults to “Posts navigation”.

参考资料

https://mor10.com/add-proper-pagination-default-wordpress-themes/

wordpress 导航相关的函数的更多相关文章

  1. WordPress导航菜单函数

    导航菜单是每一个WordPress主题必须的元素,如果你要制作一个WordPress主题,那就必须熟悉WordPress导航菜单注册函数 register_nav_menus() 和 导航菜单调用函数 ...

  2. 学习WordPress必须知道的函数(转)

    WordPress是目前十分流行的独立博客程序,因傻瓜化安装和使用,其在网民中的应用已近乎普及.但也因为很多新入门的用户几乎对WordPress 程序没有任何了解,造成使用中碰到问题无法解决,求助也十 ...

  3. 个人永久性免费-Excel催化剂功能第56波-获取Excel对象属性相关自定义函数

    之前零散开发过一些自定义函数获取Excel对象属性,此次再细细地把有价值的属性都一一给开发完成,某些场景下,有这些小函数还是可以比较方便地实现一些通过Excel界面没法轻松获取到的信息. 修复与更新 ...

  4. iOS导航控制器常用函数与navigationBar常用属性

    导航控制器常用函数触发时机 当视图控制器的View将要出现时触发 - (void)viewWillAppear:(BOOL)animated 当视图控制器的View已经出现时触发 - (void)vi ...

  5. Scala中Zip相关的函数

    在Scala中存在好几个Zip相关的函数,比如zip,zipAll,zipped 以及zipWithIndex等等.我们在代码中也经常看到这样的函数,这篇文章主要介绍一下这些函数的区别以及使用. 1. ...

  6. (转)WordPress的主查询函数-query_posts()

    今天说说WordPress 的主查询函数 -query_posts(),因为我正在制作的主题里面多次用到了这个函数 . query_posts()查询函数决定了哪些文章出现在WordPress 主 循 ...

  7. python字符串 列表 元组 字典相关操作函数总结

    1.字符串操作函数 find 在字符串中查找子串,找到首次出现的位置,返回下标,找不到返回-1 rfind 从右边查找 join 连接字符串数组 replace 用指定内容替换指定内容,可以指定次数 ...

  8. c/c++ 图相关的函数(二维数组法)

    c/c++ 图相关的函数(二维数组法) 遍历图 插入顶点 添加顶点间的线 删除顶点 删除顶点间的线 摧毁图 取得与v顶点有连线的第一个顶点 取得与v1顶点,v1顶点之后的v2顶点的之后的有连线的第一个 ...

  9. linux新定时器:timefd及相关操作函数

    timerfd是Linux为用户程序提供的一个定时器接口.这个接口基于文件描述符,通过文件描述符的可读事件进行超时通知,所以能够被用于select/poll的应用场景. 一,相关操作函数 #inclu ...

随机推荐

  1. Tactical Multiple Defense System 二分图

    This problem is about a war game between two countries. To protect a base, your country built a defe ...

  2. Mac 自带 apache

    1.启动服务器 sudo apachectl start http://localhost   能访问就ok sudo apachectl stop sudo apachectl restart ht ...

  3. R语言常用命令

    data() 列出当前已安装包中所有可用的实例数据集 help("name") 查看帮助文档  summary()  

  4. JavaScript类型转换

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. HDU4871 Shortest-path tree(最短路径树 + 树的点分治)

    题目大概要先求一张边有权的图的根为1的最短路径树,要满足根到各点路径序列的字典序最小:然后求这棵最短路径树包含k个结点的最长路径的长度和个数. 首先先构造出这棵字典序最小的最短路径树..好吧,我太傻逼 ...

  6. How to retrieve instance parameters from an uninstantiated (uninserted) family

    The trick to be able to read the default values for instance parameters is to get to the FamilyManag ...

  7. 使用 smartupload 上传图片

    使用  smartupload  请参见 elleniou 的 博客 : http://www.cnblogs.com/elleniou/archive/2012/09/24/2700583.html

  8. CentOS 命令【备忘】

    1.查看物理cpu个数 grep 'physical id' /proc/cpuinfo | sort -u | wc -l 2.查看核心数量 grep 'core id' /proc/cpuinfo ...

  9. NOIp 2014 #2 联合权值 Label:图论 !!!未AC

    题目描述 无向连通图G 有n 个点,n - 1 条边.点从1 到n 依次编号,编号为 i 的点的权值为W i ,每条边的长度均为1 .图上两点( u , v ) 的距离定义为u 点到v 点的最短距离. ...

  10. [Leetcode] Palindrome Partitioning

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...