WordPress的如何将带参数的一个URL重写为另一个漂亮的URL?

问题描述

我要重写网址

https://example.com/arenda-avtomobilej-2/?min_price=300&max_price=1200&limo-vip=on&wwf=on

https://example.com/arenda-avtomobilej-2/somepage/

保存所有get参数以查询vars。

有人可以帮忙吗?

解决方法

add_rewrite_rule() [see]

添加将URL结构转换为一组查询变量的重写规则。

add_action('init',function() {
    add_rewrite_rule( 'min_price/([0-9]+)[/]?$','index.php?min_price=$matches[1]','top' );
} );

// https://example.com/arenda-avtomobilej-2/min_price/800

[See also]