0

I'm facing a strange problem with the subcategory page pagination. I had the same problem with pagination in category page, solved with this snippet in functions.php:

function custom_pre_get_posts( $query ) {  

    if( $query->is_main_query() && !$query->is_feed() && !is_admin() && is_category()) {  

        $query->set( 'paged', str_replace( '/', '', get_query_var( 'page' ) ) );  }  } 



    add_action('pre_get_posts','custom_pre_get_posts'); 

    function custom_request($query_string ) { 

         if( isset( $query_string['page'] ) ) { 

             if( ''!=$query_string['page'] ) { 

                 if( isset( $query_string['name'] ) ) { unset( $query_string['name'] ); } } } return $query_string; } 


    add_filter('request', 'custom_request');

However it seems not working with SUBcategory pages. So:

https://mywebsite/category/page/2 -> gives the correct pagination https://mywebsite/category/subcategory/page/2 -> gives back 404 error

How can I solve the problem?

Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.