我正在寻找一种方法来分页我的get\\u帖子:
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$args = array(
\'posts_per_page\' => 5,
\'offset\' => 0,
\'orderby\' => \'post_date\',
\'order\' => \'DESC\',
\'post_type\' => \'post\',
\'post_status\' => \'publish\',
\'suppress_filters\' => true,
\'paged\' => $paged,
);
$query = get_posts($args);
我一直在努力独自完成这项任务,但没有成功。这是我的分页功能:
function my_pagination($query = false){
global $wp_query;
if ( !$query ) $query = $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
\'base\' => str_replace( $big, \'%#%\', esc_url( get_pagenum_link( $big ) ) ),
\'format\' => \'?paged=%#%\',
\'current\' => max( 1, get_query_var(\'paged\') ),
\'total\' => $query->max_num_pages,
\'type\' => \'list\',
\'prev_text\' => __(\'%s Previous\',\'textdomain\'),
\'next_text\' => __(\'Next %s\',\'textdomain\'),
) );
}
我在模板中调用它时使用:
if ( function_exists(\'my_pagination\') ) my_pagination($query);
任何帮助都将不胜感激。