Problem with specific pagination
-
Hello Guys ,
I have tired many times to solve pagination problems , I would like to change the way showing pagination from (View more) to page numbers like ( 1,2,3,4…)
without changing the way of the pagination in the theme
here is my code<?php function adstm_paging_nav() { global $wp_query; $posts_per_page = isset( $wp_query->query_vars[ 'posts_per_page' ] ) && intval( $wp_query->query_vars[ 'posts_per_page' ] ) ? $wp_query->query_vars[ 'posts_per_page' ] : intval( get_option( 'posts_per_page' ) ); $big = 999999999; $paged = max( 1, get_query_var( 'paged' ) ); $count = $wp_query->found_posts; $total = ceil( $count / $posts_per_page ); $links = paginate_links( [ 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '/page/%#%', 'total' => $total, 'current' => $paged, 'type' => 'array', 'prev_text' => '<i class="arrowleft"></i>', 'next_text' => '<i class="arrowright"></i>' ] ); $pagination = []; if( $links ) { foreach( $links as $link ) { $pagination[] = [ 'active' => adstm_search_current( $link ), 'link' => $link, ]; } } if( count( $pagination ) ) { $pagination2 = $pagination; $pagprev = array_shift( $pagination2 ); $pagnext = array_pop( $pagination2 ); echo '<ul>'; foreach ( $pagination as $key => $link ) { $class = ''; if ( $link[ 'active' ] ) { $class = ' class="active" '; } echo '<li' . $class . '>' . $link[ 'link' ] . '</li>'; } echo '</ul> <div class="adappagercont"> <span class="loadmore load_more tiny_border dark_tiny">'.__('View More', 'dali').'</span> </div>'; } } add_action( 'adstm_paging_nav', 'adstm_paging_nav' ); function adstm_search_current( $string ) { if ( preg_match( '/(current)/', $string ) ) { return true; } return false; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Problem with specific pagination’ is closed to new replies.