更新时间:2023-02-23 09:20:40
你可以在 WP 中使用你的主题的functions.php:
You can do this within WP using your theme's functions.php:
add_action( 'init', 'ss_permalinks' );
function ss_permalinks() {
add_rewrite_rule(
'page/remove/([^/]+)/?',
'index.php?pagename=page&service=$matches[1]',
'top'
);
}
add_filter( 'query_vars', 'ss_query_vars' );
function ss_query_vars( $query_vars ) {
$query_vars[] = 'removeid';
return $query_vars;
}
在实施后重新保存您的永久链接设置.page
是用户访问此 URL 时要指向的页面的 slug (domain.com/page/remove/432
),并且 $matches[1]
应该是 URL 中 remove/
之后的数字.此数字可由稍后指定的变量访问,$query_vars[] = 'removeid';
/目标页面模板上的 $removeid 将是 URL 中的数字(如果已指定).
Re-save your permalink settings once after implementing. page
is the slug of the page to point to when the user access this URL (domain.com/page/remove/432
), and $matches[1]
should be the number after remove/
in the URL. This number is accessible by the variable specified later, $query_vars[] = 'removeid';
/ $removeid on the target page's template will be the number in the URL, if specified.