• Resolved Beee

    (@beee)


    I have created a custom search form. That works perfectly.

    I have added pagination. That also works (almost) perfectly.

    Now if I have the following search query/url
    https://domain.com/?s=&ssd=1&spid=home&sex%5B%5D=4

    Then the pagination link for the second page is
    https://domain.com/page/2/?s&ssd=1&sex%5B0%5D=4#038;ssd=1&sex%5B0%5D=4

    This part gets added: #038;ssd=1&sex%5B0%5D=4
    But I have no clue as to why.

    This is my pagination function:

    function get_paging() {
        global $wp_query;
    
        if ( $wp_query->max_num_pages < 2 ) {
            return false;
        }
    
        $big  = 999999999; 
        $args = array(
            'base'      => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
            'format'    => '/page/%#%',
            'total'     => $wp_query->max_num_pages,
            'current'   => max( 1, get_query_var( 'paged' ) ),
            'show_all'  => false,
            'end_size'  => 3,
            'mid_size'  => 2,
            'prev_next' => true,
            'prev_text' => __( '&laquo; Previous', 'sexdates' ),
            'next_text' => __( 'Next &raquo;', 'sexdates' ),
            'type'      => 'list',
        );
    
        return sprintf( '<div class="paginator">%s</div>', paginate_links( $args ) );
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    You don’t need to esc_url() after get_pagenum_link(), that is done within get_pagenum_link(). What you do need to do is run the result through html_entity_decode() so the query args can be properly parsed.

    Thread Starter Beee

    (@beee)

    I removed the esc_url and added html_entity_decode around pagenum_links.

    Unfortunately no change.

    *edit* but adding it around get_pagenum_link seems to do the trick.

    • This reply was modified 6 years, 9 months ago by Beee.
    Thread Starter Beee

    (@beee)

    Dude, you made my weekend.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Pagination appends search query’ is closed to new replies.