I would like to simply create an url rewrite that takes the third argument and matches it to its corresponding pages, ignoring the other two arguments.
domain.com/argument1/argument2/page-slug = 'index.php?page_id=XXX';
Is it possible to call a page via it's slug instead of it's ID, or can I somehow generate the id, based on a pages slug?
UPDATE:
I actually got a lot further here now:
add_filter('rewrite_rules_array', 'mmp_rewrite_rules');
function mmp_rewrite_rules($rules) {
$newRules = array();
$newRules['bus-tours/(.+)/(.+)/(.+)/?$'] = 'index.php?bus-tours=$matches[3]';
$newRules['(.+)/?$'] = 'index.php?pagename=$matches[1]';
//$newRules['bus-tours/(.+)/(.+)/?$'] = 'index.php?pagename=$matches[2]';
return array_merge($newRules, $rules);
}
What this allows me is:
/bus-tours -> and it shows the bus-tours pages.
/bus-tours/California -> and it shows me the child page of bus-tours, which is Calfironia
/bus-tours/california/SanFran/Tourx -> and it shows me the CPT post for TourX
So, pretty good for now. Tho, since I am using a lot of CPT's I would like to modify the first rule so "bus-tours" can be replaced with a variable.
$newRules['(.+)/(.+)/(.+)/(.+)/?$'] = 'index.php?$matches[1]=$matches[3]';
This doesn't work. Any help here?
Thanks, Daniel