function add_rewrite_tag($tagname, $regex) {}

Add a new tag (like %postname%).
Warning: you must call this on init or earlier, otherwise the query var addition stuff won’t work.


  • string $tagname
  • string $regex

Source code

function add_rewrite_tag($tagname, $regex) {


	if ( strlen($tagname) < 3 || $tagname[0] != '%' || $tagname[strlen($tagname)-1] != '%' )


	$qv = trim($tagname, '%');

	global $wp_rewrite, $wp;


	$wp_rewrite->add_rewrite_tag($tagname, $regex, $qv . '=');



No comments yet... Be the first to leave a reply!

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 )

Twitter picture

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

Facebook photo

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

Connecting to %s

%d bloggers like this: