Custom Permalink structure
-
Hello,
what I would like to do is adding a rewrite-rule that redirects me to a certain wordpress-page and passes an additional variable, like this:WORDPRESS/index.php/singapore/hello
–> index.php?page_id=67&gallery=hello
Thats what I do now:
add_action('rewrite_rules_array',array($this,'singaporeRewriteRules'));
function singaporeRewriteRules($rewrite)
{
global $wp_rewrite;
// add rewrite tokens
$keytag_token = '%gallery%';
$wp_rewrite->add_rewrite_tag($keytag_token, '(.+)', 'page_id='.get_option('singapore_page').'&gallery=');
$keywords_structure = $wp_rewrite->root ."singapore/$keytag_token";
$keywords_rewrite = $wp_rewrite->generate_rewrite_rules($keywords_structure);
return ( $rewrite + $keywords_rewrite);
}This is what I get in the rewrite_rules_array:
[index.php/singapore/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?page_id=67&gallery=$matches[1]&feed=$matches[2]
[index.php/singapore/(.+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?page_id=67&gallery=$matches[1]&feed=$matches[2]
[index.php/singapore/(.+)/page/?([0-9]{1,})/?$] => index.php?page_id=67&gallery=$matches[1]&paged=$matches[2]
[index.php/singapore/(.+)/?$] => index.php?page_id=67&gallery=$matches[1]
Well, nice, but it doesn’t work. What do I do?
- The topic ‘Custom Permalink structure’ is closed to new replies.