Paginate links repeating value in links
-
I would like the pagination of a certain page to look like this:
site.com/page-name/page/2/paged2/1
so I used this:
<?php global $wp_rewrite, $wp_query_videos; $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1; //$paged2 = isset( $_GET['paged2'] ) ? (int) $_GET['paged2'] : 1; (isset($wp_query->query_vars['paged2']) ? ($wp_query->query_vars['paged2'] > 1 ? $current2 = $wp_query->query_vars['paged2'] : $current2 = 1) : $current2 = 1) ; $big = 999999999; // need an unlikely integer $classiera_pagination = array( //'base' => str_replace($big,"{$current}/paged2/%#%", esc_url( get_pagenum_link( $big ) ) ), 'format' => 'page/%#%', 'total' => $wp_query_videos->max_num_pages, 'current' => $current2, 'show_all' => false, 'type' => 'plain', //'add_args' => array( 'paged' => $current, 'paged2' => $paged2) ); if( $wp_rewrite->using_permalinks() ) $classiera_pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg('s',get_pagenum_link(1) ) ) . "page/{$current}/paged2/%#%", 'paged'); /* if( !empty($wp_query->query_vars['s']) ) $classiera_pagination['add_args'] = array('s'=>get_query_var('s')); */ echo '<div class="pagination">' . paginate_links($classiera_pagination) . '</div>'; ?>
and this rules of rewriting
function wpse21802_init(){ global $wp_rewrite; $wp_rewrite->flush_rules(); add_rewrite_rule( '([^/]+)/page/([^/])/?$', 'index.php?pagename=$matches[1]&paged=$matches[2]'); add_rewrite_rule( '([^/]+)/page/([^/])/paged2/([^/])/?$', 'index.php?pagename=$matches[1]&paged=$matches[2]&paged2=$matches[3]'); } add_action( 'init', 'wpse21802_init', 10, 0);
but a problem happens … after I use the page once to go for example to page 2
site.com/page-name/page/1/paged2/2/
the paging links are getting like this for page 1
site.com/page-name/page/1/paged2/2/page/1/paged2/1/
This is generating error at the time of paging. What may be the problem?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Paginate links repeating value in links’ is closed to new replies.