Default post type pagination page 2 404 error
-
Hi!
I have to change the default post type slug, because it is the child of an another Page. I used this in my functions.php:
add_action( 'init', 'my_new_default_post_type', 1 ); function my_new_default_post_type() { register_post_type( 'post', array( 'labels' => array( 'name_admin_bar' => _x( 'Post', 'add new on admin bar' ), ), 'public' => true, 'show_in_menu' => false, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'map_meta_cap' => true, 'hierarchical' => false, 'rewrite' => array( 'slug' => 'aktualis/hirek-aktualis', 'with_front' => false ), 'query_var' => false, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ), ) ); }
It worked, but when I get the posts with a query, my pagination does not work, it returns 404 page.
The Query:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $news = new WP_Query(array( 'post_type' => 'post', 'posts_per_page' => 3, 'paged' => $paged )); if($news->have_posts()) : while($news->have_posts()) : $news->the_post(); //The content endwhile; wp_reset_postdata(); endif;
And the pagination:
$pagination = paginate_links(array( 'total' => $news->max_num_pages, 'current' => $paged, 'show_all' => false, 'type' => 'list', 'base' => get_permalink(get_the_ID()).'%_%', 'format' => 'page/%#%', 'end-size' => 3, 'mid-size' => 0, 'prev_text' => 'prevlabel', 'next_text' => 'nextlabel' ));
I tried everything that come to my mind to fix this. But still have no solution. Has everyone the same problem and the solution for this?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Default post type pagination page 2 404 error’ is closed to new replies.