Help with a custom rewrite

Your best bet is to use the WordPress rewrite API. No .htaccess required. First, hook into init and add a rewrite endpoint to your permalinks. This tells WordPress that whens some visits /category/post-slug/gallery match the new endpoint rewrite. it also takes care of adding the query variable for you so you don’t have to do … Read more

HowTo to add my rewrite rules at the beginning, redirect to the right page and flush the rules on plugin activation?

Parameter in add_permastruct() The third parameter of add_permastruct() is for the is_front parameter. This is a basename, which you can add to the default permalink structure of all your posts in the WordPress admin. For example, if you have set the permalink structure to /blog/%postname% the word blog will be prepended to your rule. In … Read more

Flushing rewrite rules

What flush_rewrite_rules(); does is call $wp_rewrite->flush_rules(); (Also called when updating permalinks). All plugins rewrite rules are regenerated then, so you dont need to worry about other plugins rules being “missing”. Also is not a good idea to call this function (flush_rewrite_rule) on hooks that run each time wordpress is loaded, and is enough to call … Read more

Creating author Specific page URL

Your example works if I delete the newline. So this should work: function add_my_rule() { add_rewrite_tag(“%args%”, ‘([^/]*)’, ‘args=”); add_rewrite_rule(“writer/([^/]*)’,’index.php?pagename=writer&args=$matches[1]’,’top’); } add_action(‘init’, ‘add_my_rule’);

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.

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

WordPress plugin url for form submit

It doesn’t need a new submit URL, most of the plugins submit the form on the same page(the one on which the form was rendered), then before rendering the form they check if there is submitted data present. Then for eg. if data is present then they have to show a thankyou message & skip … Read more