简体   繁体   中英

Pagination in page problems with wordpress

I need help with wordpress pagination for custom post type. I turned off has_archive. And printing posts in page, and when I try to create pagination, it creates them but when i get to the link

/atsiliepimai/page/2/

always 404 - Page not found, how to fix this trash system, because when i change linking to

/?page_id=136&page=2

It works perfectly, how to solve this wordpress problem, here is my query args:

$paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
$args = array(
  'post_type' => 'atsiliepimai',
  'post_status' => 'publish',
  'posts_per_page' => 3,
  'paged' => $paged,
  'page' => $paged
);

$atsiliepimai = new WP_Query( $args );

Can you check if mod_rewrite is enabled on your server? If not, try to enable it and see if the problem is resolved.

The 'page' variable is used for a static front page - unless this is a static front page, change your $paged variable to

$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; (note the 'paged' instead of 'page').

Also, you can remove the last parameter 'page' => $paged

https://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM