Pagination link returns 404 with custom rewrite
-
Hi,
I have a custom post type set up called ebooks. I use BeaverBuilder to have a post grid shown on a page, with pagination. This page is called ebooks, and it has the page Resources set as parent. The code for the pagination is the following:public static function pagination( $query ) { $total_pages = $query->max_num_pages; $permalink_structure = get_option( 'permalink_structure' ); $paged = FLBuilderLoop::get_paged(); $base = html_entity_decode( get_pagenum_link() ); $add_args = false; if ( $total_pages > 1 ) { if ( ! $current_page = $paged ) { // @codingStandardsIgnoreLine $current_page = 1; } $base = FLBuilderLoop::build_base_url( $permalink_structure, $base ); $format = FLBuilderLoop::paged_format( $permalink_structure, $base ); // Flag if it's a first posts module in an archive page. // Fix pagination issues in archive page since it's using the main WP query for pagination. if ( $query->is_archive && 1 === FLBuilderLoop::$loop_counter ) { if ( isset( $query->query['settings']->data_source ) && 'custom_query' === $query->query['settings']->data_source ) { $add_args = array( 'flpaging' => 1, ); } } // phpcs:ignore echo paginate_links( array( 'base' => $base . '%_%', 'format' => $format, 'prev_text' => '<span class="btn btn-secondary btn-sm">' . __( 'Newer posts', 'memoq_bb' ) . '</span>', 'next_text' => '<span class="btn btn-secondary btn-sm">' . __( 'Older posts', 'memoq_bb' ) . '</span>', 'current' => $current_page, 'total' => $total_pages, 'type' => 'plain', 'add_args' => $add_args, ) ); }
The link on the older posts button is https://mysite.com/resources/ebooks/page/2 .
Post type slug: ebook
Has archive: false
Custom rewrite slug: resources/ebooksWhen I have the Rewrite option set to true, the pagination button link goes to 404, when it is set to false, it works fine. Both times the link on the button is the same.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Pagination link returns 404 with custom rewrite’ is closed to new replies.