开发

WordPress 文章列表添加分页功能

将代码直接应用在页面模板中

global $wp_query;
  $max = 999999999;
  echo paginate_links( 
  array(
    'base' => str_replace( $max, '%#%', esc_url( get_pagenum_link( $max ) ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged')),
    'total' => $wp_query->max_num_pages,
    'prev_text' => 'Previous',
    'next_text' => 'Next'
  )
);

https://developer.wordpress.org/reference/functions/paginate_links/

PUJI Design 朴及设计 (c) 2024. 沪ICP备17052229号