Keep requested/entered url with add_rewrite_rule

Okay I figured it out. Instead of using this rewrite rule: add_rewrite_rule(‘^somepage/([^/]*)/([^/]*)/([^/]*)/?’,’index.php?p=27&target=$matches[1]&arrival=$matches[2]&departure=$matches[3]’,’top’); I now use this one: add_rewrite_rule(‘^somepage/([^/]*)/([^/]*)/([^/]*)/?’,’index.php?pagename=somepage&target=$matches[1]&arrival=$matches[2]&departure=$matches[3]’,’top’); And now everything works like I wanted it to. Obviously using the page id instead of the page name was the problem.

Problems with rewrite rule

I suspect you have a conflict with your query vars. id is already a WordPress query var, and type is a reserved word. You should use vars that you know will be unique among core and any plugin you may use by prefixing everything, like zilvinas_id and zilvinas_type.

custom wordpress rewrite

WordPress has two kinds of rewrite rules- internal and external. Internal rules are parsed by WordPress and routed to index.php. External rewrites get written to .htaccess and are not directed to WordPress. Right now your rule is a mix between internal and external- you have it structured as an internal rule, but you have it … Read more

Localize URL bases

This should cover everything: function wpa_rewite_translate(){ global $wp_rewrite; $wp_rewrite->pagination_base=”pagina”; $wp_rewrite->author_base=”autor”; $wp_rewrite->comments_base=”comentarios”; $wp_rewrite->feed_base=”alimentar”; $wp_rewrite->search_base=”busqueda”; $wp_rewrite->set_category_base( ‘categoria/’ ); $wp_rewrite->set_tag_base( ‘etiqueta/’ ); } add_action( ‘init’, ‘wpa_rewite_translate’ ); Feel free to laugh at my translations, haha. Also, to flush rewrite rules when your theme is activated, add this: function wpa_flush_rewite(){ flush_rewrite_rules(); } add_action( ‘after_switch_theme’, ‘wpa_flush_rewite’ );

Custom url rewriting

[answer updated as wanted] It’s better to hook your function to generate_rewrite_rules so you won’t have fall into infinite loops and flushing rewrite rule on every request. So you can do this: function add_my_rules($wp_rewrite) { $new_rules = array( ‘^cityprofile/\?city=(Sydeny|Melbourne|Brisbane)$’ => $wp_rewrite->preg_index(1) // for 3 cities ); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_action(‘generate_rewrite_rules’, ‘add_my_rules’); and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)