我在WordPress论坛上得到了答案。下面是那些希望做类似事情的人的工作代码:
add_filter( \'post_type_link\', \'change_webinar_links\', 10, 2 );
function change_webinar_links( $link, $post) {
if ( $post->post_type == \'tribe_events\' && tribe_event_in_category(\'webinar\') ) {
$link = trailingslashit( home_url(\'/webinars/\' . $post->post_name ) );
}
return $link;
}
add_action( \'init\', \'webinar_rewrite_rule\', 5);
function webinar_rewrite_rule() {
add_rewrite_rule( \'^webinars/([^/]+)\', \'index.php?tribe_events=$matches[1]&post_type=tribe_events&name=$matches[1]\', \'top\' );
}