zoukankan      html  css  js  c++  java
  • wordpress 导航相关的函数

    上一篇文章、下一篇文章

    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/

  • 相关阅读:
    [bzoj3524]Couriers
    [bzoj2789]Letters
    [bzoj4318]OSU!
    [luogu4570]元素
    [hdu6600]Just Skip The Problem
    [bzoj5025]单调上升路径
    [bzoj4557]侦察守卫
    [hdu5379]Mahjong tree
    [bzoj2957]楼房重建
    [noi253]A
  • 原文地址:https://www.cnblogs.com/flowerszhong/p/5479468.html
Copyright © 2011-2022 走看看