Custom Wildcard Permalink Structure
-
OK, so this is a bit of a different one but let’s see if anyone can think of a simple solution …
What we want is to be able to set a global permalink structure of, for example …
/%variable_one%/%variable_two%/%postname%/
… so that the base URL of the entire site is …
example.com/%variable_one%/%variable_two%/
Essentially I want WordPress to expect to be found two directory levels deep which can be anything and will be used on a custom basis by a theme / plugin.
1) The current variable_one and variable_two values need to be able to be received by, for example $wp_query->query_vars[‘variable_one’]
2) Permalinks to be displayed on the current page need to be able to have these variables set depending on what type of link is being written and other criteriaWe have managed to use this …
function my_rewrite_tags() {
add_rewrite_tag( ‘%variable_one%’, ‘([^&]+)’ );
add_rewrite_tag( ‘%variable_two%’, ‘([^&]+)’ );
}
add_action(‘init’, ‘my_rewrite_tags’, 10, 0);… but cannot work out how to get WordPress to write future permalinks with what we want in (2) above.
Any ideas?
Thanks,
Oliver
- The topic ‘Custom Wildcard Permalink Structure’ is closed to new replies.