• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Question: My pagination creates a redirect

alikiani

Member
Sep 14, 2019
35
16
8
Maybe someone can help me. I checked many sites but I didn't find the right answer
Because you Babiatoes always helped me
Can you help me this time to fix this problem

my code is:

Code:
public function numeric_pagination() {
        global  $wp_query , $wp_rewrite;;
        if ( $wp_query->max_num_pages < 2 ) {
            return;
        }
        $paged        = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
        $pagenum_link = html_entity_decode( get_pagenum_link() );
        $total        = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
        $url_parts    = explode( '?', $pagenum_link );
        $pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';
        $format       = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
        $format      .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
        $links = paginate_links( array(
            'base'     => $pagenum_link,
            'format'   => $format,
            'total'    => $wp_query->max_num_pages,
            'current'  => $paged,
            'total'    => $total,
            'mid_size' => 1,
            'prev_text' => '«',
            'next_text' => '»',
            'type'      => 'array',
        ) );
        if( is_array( $links ) ) {
            $pagination  = '<div class="pagination-wrap"><ol class="pagination">';
            foreach ( $links as $page_key => $page) {
                $pagination .= "<li>$page</li>";
            }
            $pagination .= '</ol></div>';
            return $pagination;
        }
        return false;
    }

and my problem is
At the end the category main page link gives a "/" which causes redirection 301

example:
mysite.com/category/ -> redirect to mysite.com/category

i need remove / in category main page

The rest of the pages are correct
example:
mysite.com/category/page/2
mysite.com/category/page/3
 
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock