我改用paginate,并使用下面的代码
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$data= new WP_Query(array(
\'post_type\'=>\'cryptoevent\', // your post type name
\'posts_per_page\' => 3, // post per page
\'paged\' => $paged,
));
if($data->have_posts()) :
while($data->have_posts()) : $data->the_post();
the_title();
php
endwhile;
?><br><?php
$total_pages = $data->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var(\'paged\'));
$big = 99999; // need an unlikely integer
echo paginate_links(array(
\'base\' => str_replace( $big, \'%#%\', esc_url( get_pagenum_link( $big ) ) ),
\'format\' => \'/page/%#%\',
\'current\' => $current_page,
\'total\' => $total_pages,
\'prev_text\' => __(\'« prev\'),
\'next_text\' => __(\'next »\'),
));
}
?>
<?php else :?>
<h3><?php _e(\'404 Error: Not Found\', \'\'); ?></h3>
<?php endif; ?>
<?php wp_reset_postdata();
如果我设置
permalinks 在…上
plain, 但我的网站永久链接设置为
post name, 请帮帮我,非常感谢。