Advertisements

add_rewrite_tag

Definition:
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.

Parameters

  • string $tagname
  • string $regex

Source code

function add_rewrite_tag($tagname, $regex) {

	//validation

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

		return;



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



	global $wp_rewrite, $wp;

	$wp->add_query_var($qv);

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

}

363

Advertisements

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:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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: