To go further in my knowledge of wordpress, I've been developing a theme from scratch, and using plugins ACF and CPT UI, in order to create a simple and intuitive backoffice interface.
My problem is on the front-end although. I've been creating pagination for the homepage (using a custom query) and it works perfectly. This is not the case when it comes to category pages (in a template named category.php).
I've been Googling for hours in order to find a solution, but everything seems related to permalinks, when I don't have any problems with permalinks (I'm using the default structure /%postname%/ ).
Here's the code for my category page, including the custom loop and pagination :
<?php $paged = ( get_query_var('page') ) ? get_query_var('page') : 1; $my_videos = new WP_Query(array( 'post_type' => 'video', 'category_name' => single_cat_title('', false), 'posts_per_page' => 6 )); if ( $my_videos->have_posts() ) : while ($my_videos->have_posts()) : $my_videos->the_post(); show_video_thumbnails(); endwhile; else: ?> <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> <?php endif; ?> <!-- pagination here --> <?php next_posts_link( 'Older Entries', $my_videos->max_num_pages ); previous_posts_link( 'Newer Entries' ); wp_reset_postdata(); ?>
Everything works great on the first page of the category: pagination is available and shows "Older entries".
But when clicking the link, I'm being redirected to /category/mycategoryname/page/2 (mycategoryname being my category name), but it shows a 404 error;
Any help would be greatly appreciated. I feel like I'm missing something here.