Category pagination not working
-
Dear support team,
We have removed the product-category form category URL by using
Custom Structure /%category%/%postname%/
Now product category pagination not working I tried to fix this issue lot of StackOverflow suggestion but not working
Can you please fix this issue?
Refer to this link: https://dextratechnologies.in/thesstudioonline/collections/page/2
Also added below code in functions.php
/*
Code Purpose : Remove woocommerce product-category slug
Author: Tutorialswebsite
*/
add_filter(‘request’, function( $vars ) {
global $wpdb;
if( ! empty( $vars[‘pagename’] ) || ! empty( $vars[‘category_name’] ) || ! empty( $vars[‘name’] ) || ! empty( $vars[‘attachment’] ) ) {
$slug = ! empty( $vars[‘pagename’] ) ? $vars[‘pagename’] : ( ! empty( $vars[‘name’] ) ? $vars[‘name’] : ( !empty( $vars[‘category_name’] ) ? $vars[‘category_name’] : $vars[‘attachment’] ) );
$exists = $wpdb->get_var( $wpdb->prepare( “SELECT t.term_id FROM $wpdb->terms t LEFT JOIN $wpdb->term_taxonomy tt ON tt.term_id = t.term_id WHERE tt.taxonomy = ‘product_cat’ AND t.slug = %s” ,array( $slug )));
if( $exists ){
$old_vars = $vars;
$vars = array(‘product_cat’ => $slug );
if ( !empty( $old_vars[‘paged’] ) || !empty( $old_vars[‘page’] ) )
$vars[‘paged’] = ! empty( $old_vars[‘paged’] ) ? $old_vars[‘paged’] : $old_vars[‘page’];
if ( !empty( $old_vars[‘orderby’] ) )
$vars[‘orderby’] = $old_vars[‘orderby’];
if ( !empty( $old_vars[‘order’] ) )
$vars[‘order’] = $old_vars[‘order’];
}
}
return $vars;
});
Hello,
Please make the full backup of your site as well as the Theme settings export and check the issue on the Storefront theme to detect if our theme causes the problem. Storefront is a free theme developed by WooСommerce.
Best Regards