[wp-trac] [WordPress Trac] #31939: paginate_links() - incorrect links on return to the first page

WordPress Trac noreply at wordpress.org
Thu Apr 9 06:44:10 UTC 2015


#31939: paginate_links() - incorrect links on return to the first page
--------------------------+-----------------------------
 Reporter:  bobbingwide   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Themes        |    Version:  4.1.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Sorry about this but this is a direct follow on to #30831.

 With the exact same piece of code that I had originally,
 when you return to the first page of the paginated content,
 none of the links contain the correct paging values...
 so they don't work.

 {{{
 function bw_navi_paginate_links( $id, $page, $pages ) {
   $base = add_query_arg( "bwscid$id", "%_%" );
   $format = "%#%";
   $args = array( "base" => $base
                , "format" => $format
                , "total" => $pages
                , "current" => $page
                , "before_page_number" => "["
                , "after_page_number" => "]"
                );

   $links = paginate_links( $args );
   e( $links );
 }
 }}}
 regardless of whether or not I attempt to apply my workaround
 {{{
               , "add_args" => false
 }}}




 === Expected output: ===

 Assume the original display is:
 {{{
 1 to 2 of 5
 one
 two
 (1) [2] [3] Next
 }}}

 and page 2 display is:

 {{{
 3 to 4 of 5
 three
 four
 Previous [1] (2) [3] Next
 }}}

 where (n) indicates it's not a link

 with WordPress 4.0, and a value of 2, for the $id the pagination links
 were

 * page 1: http://example.com/permalink/?bwscid2=
 * page 2: http://example.com/permalink/?bwscid2=2
 * page 3: http://example.com/permalink/?bwscid2=3

 You could visit page 2, then return to page 1, then visit page 2 again

 === Actual output: ===

 * On first visit the links are OK
 * When you visit page 2 the links are OK
 * When you return to page 1 all the links are broken

 http://example.com/permalink/?bwscid2

 In order to be able to page you need to remove the query parm from the
 URL.

 === Demo: ===

 For an example see http://wp-a2z.com/oik_api/paginate_links/
 and try to page forwards then backwards through the source code.

 === Workaround: ===

 Unknown. Please advise.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31939>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list