function add_rewrite_rule($regex, $redirect, $after = 'bottom') {}

Add a straight rewrite rule.


  • string $regex: Regular Expression to match request against.
  • string $redirect: Page to redirect to.
  • string $after: Optional, default is ‘bottom’. Where to add rule, can also be ‘top’.

Source code

function add_rewrite_rule($regex, $redirect, $after = 'bottom') {

	global $wp_rewrite;

	$wp_rewrite->add_rule($regex, $redirect, $after);



One Response to “add_rewrite_rule”

  1. add_rewrite_rule and add_rewrite_tag can be a serious pain if you’re implementing a custom plugin. Might try using this method:

    You can then parse the URL yourself and take over with template_redirect.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: