add_rewrite_rule

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

Add a straight rewrite rule.

Parameters

  • 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);

}

291

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:

    http://gabrielharper.com/blog/2012/09/wordpress-custom-urls-for-plugins/

    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:

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

%d bloggers like this: