(WP)一个简单的添加rewrite规则的小插件



/**
 * @package liut
 * @author liut
 * @version 0.1.2
 */
/*
Plugin Name: liut simple url add
Plugin URI: #
Description: rewrite atom.xml and rss.xml to feed/.
Author: liut
Version: 0.1.2
Author URI: http://liut.cc/
*/

add_action('init', 'liut_url_add');

function liut_url_add() {
	global $wp_rewrite;
	foreach(liut_url_custom_rewrite_rule() as $regex => $value) {
		$wp_rewrite->add_rule($regex, $value, 'top');
	}
	$wp_rewrite->flush_rules();

}

function liut_url_custom_rewrite_rule() {
	return array(
		'atom.xml' => 'index.php?feed=atom',
		'rss.xml' => 'index.php?feed=rss2',
	);
}


Comments are closed.