## Include a leading zero in pagination

I’m new to WordPress Development and have been teaching myself over the last few months how to develop a theme from scratch. Normally I can figure issues out on my own through forums, but I can’t really find much on this one.

I’ve been trying to add leading zeros to my pagination if the number is less than 10.

I.e: < Newer 01 02 03 … 10 Older >

Here is my pagination code. Any pointers in the right direction would be appreciated!

if ( !function_exists('palfrey_pagination') ) { function palfrey_pagination( $range = 5 ) { if( is_singular() ) return; //$  paged - number of the current page     global $paged,$  wp_query;      // Stop execution if there's only 1 page.     if( $wp_query->max_num_pages <= 1 ) return;$  paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;      if ( !$max_page )$  max   = intval( $wp_query->max_num_pages ); if ($  max_page > 1 )             if ( !$paged )$  paged = 1;       // Add current page to the array.     if ( $paged >= 1 )$  links[] = $paged; // Add the pages around the current page to the array. if ($  paged >= 3 ) {         $links[] =$  paged - 1;         $links[] =$  paged - 2;     }       if ( ( $paged + 2 ) <=$  max ) {         $links[] =$  paged + 2;         $links[] =$  paged + 1;     }          // The pagination     echo "\n" . '<div class="content-block-common-large">                     <div class="block-wrap">                         <div class="inline-group flex-group relative align-center column-align-bottom">                             <div class="column responsive width-450">                                 <ul class="pagination display-block relative align-center width-1of1">' . "\n";       // Link to 'Newer' posts.     if ( get_previous_posts_link() ) {         printf( '<li>%s</li>' . "\n", get_previous_posts_link( '<div class="display-inline-block relative float-left"><span class="pagination-prev">Newer</span></div>' ) );     }else{     echo '<li><div class="display-inline-block relative float-left pointer-events-none" style="opacity: .6;"><span class="pagination-prev">Newer</span></div></li>';     }          // Link to first page, plus ellipses if necessary.     if ( ! in_array( 1, $links ) ) {$  class = 1 == $paged ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n",$  class, esc_url( get_pagenum_link( 1 ) ), '1' );           if ( ! in_array( 2, $links ) ) echo '<li>…</li>'; } // Link to current page, plus 2 pages in either direction if necessary. sort($  links );     foreach ( (array) $links as$  link ) {         $class =$  paged == $link ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n",$  class, esc_url( get_pagenum_link( $link) ),$  link );     }       // Link to last page, plus ellipses if necessary.     if ( ! in_array( $max,$  links ) ) {         if ( ! in_array( $max - 1,$  links ) )             echo '<li>…</li>' . "\n";           $class =$  paged == $max ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n",$  class, esc_url( get_pagenum_link( $max) ),$  max );     }       // Link to 'Older' posts.     if ( get_next_posts_link() ) {         printf( '<li>%s</li>' . "\n", get_next_posts_link( '<div class="display-inline-block relative float-right"><span class="pagination-next">Older</span></div>' ) );     }else{     echo '<li><div class="display-inline-block relative float-right pointer-events-none" style="opacity: .6;"><span class="pagination-next">Older</span></div></li>';     }       echo "\n" . '           </ul>                         </div>                     </div>                 </div>             </div>' . "\n";       } } 

## Pagination (archive posts) getting out of hand – what to do from an SEO POV?

WordPress as many of us know creates an archive loop of old posts.

From an SEO POV, some of my categories are now at 100+ pages which is a lot of bloat…

Sure, I can set each of these paginated pages a canonical link but still, feels like it is a bit unnecessary for all these indexed pages that just contain a title and an excerpt (which is basically duplicate content..)

Is one approach to simply switch off archive loops or does Google ignore these archived pages?

Thanks

## Remove pagination from e-commerce category page while preserving SEO text relevance

I am administering an e-commerce website where currently we have pagination implemented on every category page.

On the first page of each category, we have SEO text in the bottom – a description of the category which helps our page to rank higher in search results. In many cases, it is long enough to make it impractical to place it at the top of the page.

I am flirting with the idea of converting our structure to an “infinite scroll” experience, to remove pagination altogether. I realise that this would yield some SEO benefits.

However, I am seriously worried that a lengthy list of products would dilute the importance of our category description at the bottom. I remember reading somewhere that Google places more importance on the content which is higher on the page.

Has anyone tried to implement the “infinite scroll” and did you notice any serious changes in your ranking? Or maybe you have an idea as to how it will affect the relevance of the category description at the bottom of the page?

## Two Pagination in One page with shortcode

I create a shortcode to show posts by category with attributes. I want to show 2 separate categories with a separate shortcode in one page but the pagination connected.

If I change pagination in the first shortcode, also change pagination in the second shortcode. Basically it same shortcode but different attributes.

here my code:

## Pagination of results from different sources merged by a unified scoring function

Assume a Hotel reservation scenario, given $$m$$ ranked lists of attribute values such as distance, price, amenities (normalized between $$0$$ and $$1$$), and a unifying linear score function $$F(\cdot)=\alpha_1*score_1+ \alpha_2*score_2+ \alpha_3*score_3$$, the Threshold Algorithm (TA) is optimal in finding top-$$k$$ results that have higher $$F$$ values.

However, consider a pagination scenario with page index $$p$$ and page size $$k$$. Indeed, instead of asking for top-$$k$$ that can be obtained from indices [0,k] in the final ranked list, we ask for [pk, (p+1)k]. What is the best solution to obtain this window of the results?

You may consider this problem as the pagination of the merged results over a unified scoring function when there are multiple data sources that each contains a score value but the merged results have a combined score value as a (linear) function of individual score values.

Some solutions:

Totally naive: given the multiple ranked results, compute the unified score, sort them, slice it as needed.

Potentially better but inefficient when asking lower-ranked results (farther pages): Execute Threshold Algorithm and ask for top-(p+1)k, return the [pk, (p+1)k] from it.

## ‘Select All Visible’ vs ‘Select All’ with pagination

Suppose I have a table with pagination due a lot of row entries. Should the default action for ‘Select all’ select the entries on the current page or all entries in the entire table (i.e. all pages)?

What is the intended behaviour for a user?

I am aware of the solution that Gmail has to address this where it selects the ones in view and prompts an action to select all. Just wondering where I could find some other examples of products tackling this.

## Pagination on grouped / multi sorted lists

I’m currently working on a design for data heavy lists. User research showed, that users would group / multi sort those lists. this would result in a list with small header rows in between for every sort parameter.

So far so good. I’m now having a hard time, as those lists have a pagination. I would now also need to show the grouped rows over all pages which might take the user out of context…

any thoughts on how to solve the problem?

Cobo

## Numbered Pagination Showing The Same Posts After Altering WP_Query

I think the title sums the problem up, but I’ll explain more with the code below.

As you can see, I’m trying to start the loop from the second latest post for some theme reasons which forced me to alter the main loop, and I used the parameter offset to make that work, and everything worked just fine, but after I moved on with the development, I started developing the numbered pagination, and finally got surprised with my altered loop showing the same posts in every page.

I chose to use WP_Query and not touch query_posts(), as it’s simple and faster, now I’m stuck with this problem, and tested everything and didn’t work.

Here is the altered loop using class WP_Query:

<?php     $paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : 1;$  args = array(        'offset' => 1,        'post_type'  => 'post',        'paged'      => $paged );$  offset_loop = new WP_Query( $args ); ?> <?php if ($  offset_loop->have_posts() ): ?>     <?php while ( $offset_loop->have_posts() ):$  offset_loop->the_post(); ?>         <div class="blog_loop_container">             <article class="blog_post <?php post_class(); ?>" id="post-<?php the_ID(); ?>">                 <div class="post_thumbnail"><?php the_post_thumbnail( 'medium_large' ); ?></div>             </article>         </div>     <?php endwhile; ?>      <?php // wp_reset_postdata(); ?>     <?php echo thegreatguy_pagination(); ?> <?php endif; ?> 

And here is the pagination function i’m using :

function thegreatguy_pagination() {     global $wp_query; // Calling The Global Variable Representing WP_Query Class.$  totalPages = $wp_query->max_num_pages; // Retrieves The Maximum Pages The Blog has.$  currentPage = max( 1, get_query_var( 'paged' ) ); // Retrieves The Number Of The Current Page.      if ( $totalPages > 1 ) { // Check For More Pages To Return. return paginate_links( array( 'format' => 'page/%#%', 'base' => get_pagenum_link() . '%_%', 'current' =>$  currentPage,             'prev_text'     => 'Previous',             'next_text'     => 'Next'         ) );     } }