My setup is as follows:
- Taxonomy called ‘region’
- Terms in this taxonomy like ‘scotland’
- Various post types that use this single taxonomy
I have achieved functioning pretty permalinks of the following format using the rewrite rule below:
add_rewrite_rule(
'region/([^/]+)/([^/]+)/([^/]+)/?',
'index.php?taxonomy=region&term=$matches[1]&post_type=$matches[3]',
'top'
);
This give me a functioning URL like:
http://example.com/region/scotland/type/event/
which is exactly what I need (region/[scotland] = taxonomy, type/[event] = post type)
However, I’ve tried adding an additional add_rewrite_rule to deal with pagination in the following URL format (I really don’t get on well with regex!) but I just can’t get pagination to function correctly – I’m was aiming to achieve the following:
http://example.com/region/scotland/type/event/page/1
http://example.com/region/scotland/type/event/page/2
http://example.com/region/scotland/type/event/page/3
I think I’m nearly there as I have one rewrite rule functioning correctly – but after trying lots of different things I’ve just not been able to achieve the correct regex/rewrite rule combination to achieve the pagination. The not-so-pretty permalink for this query, which functions correctly is:
http://example.com/index.php?taxonomy=region&term=scotland&post_type=event&paged=1