title: Woocommerce - Pagination links reload same page content in a custom template
body: <p>I'm trying to build my own custom downloads.php template. Everything works fine except pagination. The error occurs when clicking on any page number, for example; if you click on page 2 the link changes from mywebsite.com/account/downloads to mywebsite.com/account/downloads/2 but the content of the page is the same as the first page.</p>
  <p>I've been looking around for my own problem but can't find a solution that works for me:</p>
  <p><a href="https://wordpress.stackexchange.com/questions/120407/how-to-fix-pagination-for-custom-loops">https://wordpress.stackexchange.com/questions/120407/how-to-fix-pagination-for-custom-loops</a></p>
  <p><a href="https://stackoverflow.com/questions/71873725/wordpress-custom-post-type-pagination-reloads-same-content-on-every-page">Wordpress Custom Post Type: Pagination reloads same content on every page</a></p>
  <p>There are other similar questions without an accepted answer, but they all agree that you have to define your own query for paged variable.</p>
  <p>Can anyone clarify this? I would be very grateful, I appreciate any help, thank you.</p>
  <p>Update: I fixed some errors I was getting on the display when wp_debug is true. Now I no longer have any errors but the problem of the carimaneto of the same page remains.</p>
  <p><strong>My custom template</strong></p>
  <pre><code>&lt;?php
  
  ?&gt;&lt;div class=&quot;orders-container&quot;&gt;&lt;?php
  
  
  defined( 'ABSPATH' ) || exit;
  
  // Variable for Array $args ($customer_orders)
  $order_statuses = array('wc-completed');
  $current_page = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
  
  //Custom Query
  $args = array(
      'customer_id' =&gt; get_current_user_id(),
      'post_status'     =&gt; $order_statuses,
      'paged'           =&gt; $current_page,
      'posts_per_page'  =&gt; 8,
      'paginate'        =&gt; true,
  );
  $customer_orders = wc_get_orders( $args );
  
  // Start if Condition
  if ( $customer_orders ) {
                  
   ?&gt;&lt;table class=&quot;table_orders heading&quot;&gt;&lt;tr&gt;
    &lt;td class=&quot;product_number&quot;&gt;Ordine&lt;/td&gt;
    &lt;td class=&quot;product_name&quot;&gt;Prodotto&lt;/td&gt;
    &lt;td class=&quot;product_data&quot;&gt;Data&lt;/td&gt;
    &lt;td class=&quot;product_price&quot;&gt;Totale&lt;/td&gt;
    &lt;td class=&quot;product_status&quot;&gt;Stato&lt;/td&gt;
    &lt;td class=&quot;product_action&quot;&gt;File&lt;/td&gt;
   &lt;/tr&gt;&lt;/table&gt;&lt;?php
  
      foreach($customer_orders-&gt;orders as $order){
          $orders_id = $order-&gt;get_id();
          $date_created = $order-&gt;get_date_created()-&gt;date('d/m/Y');
          $order_total = $order-&gt;get_formatted_order_total();
          $status =  wc_get_order_status_name( $order-&gt;get_status() );
          $view_order = $order-&gt;get_view_order_url();
  
          foreach($order-&gt;get_items() as $item_id =&gt; $item){
              $product_name = $item-&gt;get_name();
  
              echo '
                  &lt;table class=&quot;table_orders&quot;&gt;
                  &lt;tr class=&quot;table_row_items&quot;&gt;
                      &lt;td class=&quot;product_number&quot;&gt;
                       &lt;span class=&quot;mobile title&quot;&gt;Ordine&lt;/span&gt;
                       &lt;span&gt;#'. esc_attr($orders_id) .'&lt;/span&gt;
                      &lt;/td&gt;
      
                      &lt;td class=&quot;product_name&quot;&gt;
                       &lt;span class=&quot;mobile title&quot;&gt;Prodotto&lt;/span&gt;
                       &lt;a href=&quot;'. wp_kses_post($view_order) .'&quot;&gt;'. wp_kses_post($product_name) .'&lt;/a&gt;
                      &lt;/td&gt;
      
                      &lt;td class=&quot;product_data&quot;&gt;
                       &lt;span class=&quot;mobile title&quot;&gt;Data&lt;/span&gt;
                       &lt;span&gt;'. wp_kses_post($date_created) .'&lt;/span&gt;
                      &lt;/td&gt;
      
                      &lt;td class=&quot;product_price&quot;&gt;
                       &lt;span class=&quot;mobile title&quot;&gt;Prezzo&lt;/span&gt;
                       &lt;span&gt;'. wp_kses_post($order_total) .'&lt;/span&gt;
                      &lt;/td&gt;
      
                      &lt;td class=&quot;product_status&quot;&gt;
                       &lt;span class=&quot;mobile title&quot;&gt;Stato&lt;/span&gt;
                       &lt;span class=&quot;label ' . $order-&gt;get_status() . '&quot;&gt;'. wp_kses_post($status) .'&lt;/span&gt;
                      &lt;/td&gt;
   
                      &lt;td class=&quot;product_action&quot;&gt;
                       &lt;span class=&quot;mobile title&quot;&gt;File&lt;/span&gt;
                       &lt;a target=”_blank” href=&quot;'. esc_url($view_order) .'&quot;&gt;Visualizza&lt;i class=&quot;fa-duotone fa-eye&quot;&gt;&lt;/i&gt;&lt;/a&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;    
                  &lt;/table&gt; 
              ';
          }   
      }
  
      // Pagination button - Responsabile dei bottoni e numerazione delle pagine della cronologia ordini
      ?&gt;&lt;div class=&quot;container-pagination&quot;&gt;&lt;?php 
          $args = array(
           'base'          =&gt; esc_url( wc_get_endpoint_url( 'my-endpoint' ) ) . '%_%', //Here I put my custom endpoint
           'format'        =&gt; '%#%',
           'total'         =&gt; $customer_orders-&gt;max_num_pages,
           'current'       =&gt; $current_page,
           'show_all'      =&gt; false,
           'end_size'      =&gt; 3,
           'mid_size'      =&gt; 3,
           'prev_next'     =&gt; true,
           'prev_text' =&gt; __('&lt;i class=&quot;fa-regular fa-angle-left&quot;&gt;&lt;/i&gt;&lt;span&gt;Indietro&lt;/span&gt;'), 
           'next_text' =&gt; __('&lt;span&gt;Avanti&lt;/span&gt;&lt;i class=&quot;fa-regular fa-angle-right&quot;&gt;&lt;/i&gt;'),
           'type'          =&gt; 'plain',
           'add_args'      =&gt; false,
           'add_fragment'  =&gt; ''
          ); 
      echo paginate_links($args);   
  }       
  
  else {
      ?&gt;&lt;div class=&quot;msg_orders&quot;&gt;La tua cronologia ordini è vuota!&lt;/div&gt;&lt;?php
  } 
  
  ?&gt;&lt;/div&gt;&lt;?php
      
  
  ?&gt;
  &lt;/div&gt;
  </code></pre>