在功能上。php我正在为此url添加重写规则:
http://www.myblog.com/?currentpage=1
http://www.myblog.com/?currentpage=2
等等。。。
这是我使用的代码,你能给我重写规则,把我的URL转换成漂亮的URL吗?
add_action( \'init\', \'wpa5413_init\' );
function wpa5413_init() {
// Remember to flush the rules once manually after you added this code!
add_rewrite_rule(
\'Please add my rewrite rule\',
\'Please add my rewrite rule\',
\'top\' );
}
add_filter(\'query_vars\', \'wpa3537_query_vars\');
function wpa3537_query_vars($query_vars) {
$query_vars[] = \'currentpage\';
return $query_vars;
}
泰!
最合适的回答,由SO网友:Bainternet 整理而成
如果你想
那么您的功能应该是
add_action(\'generate_rewrite_rules\', \'currentpage_rewrite_rule_222\');
function currentpage_rewrite_rule_222($wp_rewrite){
$newrules = array();
$new_rules[\'currentpage/(\\d*)$\'] = \'index.php?currentpage=$matches[1]\';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
只需保持query\\u vars的功能不变即可。
add_filter(\'query_vars\', \'wpa3537_query_vars\');
function wpa3537_query_vars($query_vars) {
$query_vars[] = \'currentpage\';
return $query_vars;
}