简体   繁体   中英

Wordpress Rewrite URL with params

I have the following url and I'm using the type parameter in a WP_Query to generate a list of posts.

http://wordpress.dev/en-ie/category-holiday-deals/?type=city-breaks

I want to rewrite the url so it looks like this:

http://wordpress.dev/en-ie/holiday-deals/city-breaks

but I want to be able to use the type param still.

I have the following that's capturing the query vars:

add_filter('query_vars', 'sd_query_vars', 10, 1);

function sd_query_vars($vars) {
    $vars[] = 'type';
    $vars[] = 'destination';
    return $vars;
}

but I can't figure out how to rewrite the URL.

Any suggestions?

Whenever I've had to handle redirects with WordPress, I have used a plug-in like Rewrite . It gives you a nice interface to create rewrite rules.

I've found it's a lot easier than fiddling with the .htaccess file directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM