Ok, so I know it's a silly title, but it's exactly how I feel right now..
I've created some custom rewrites for WordPress and they work great, the only problem is that now I need to add pagination. My rules are messing with the pagination and vice versa. The page url will update when I click on a pagination link, but the query stays the same..
Here's what I have in my functions.php
// ADD REWRITE FOR VIDEOS -> GROUP
add_rewrite_tag('%group%','([^&]+)');
// ADD REWRITE FOR VIDEOS -> VALUE
add_rewrite_tag('%value%','([^&]+)');
// ADD REWRITE FOR VIDEOS TO ACCEPT GROUP & VALUE
add_rewrite_rule('^car-videos/group/([^/]*)/value/([^/]*)/?','index.php?page_id=40&group=$matches[1]&value=$matches[2]','top');
Here's my pagination code
<div class="pagination">
<?php $total_pages = $loop->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => 'page/%#%',
'current' => $current_page,
'total' => $total_pages,
'prev_text' => __('Previous'),
'next_text' => __('Next')
));
}
?>
</div>
Here's how I'm getting the group and value variables
$urlGroup = $wp_query->query_vars['group'];
$urlValue = $wp_query->query_vars['value'];
I use this in my WP_Query
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
How would I rewrite the rule to allow for pagination? Is there something I'm doing wrong?