WordPress需要使用伪静态地址(mobantu.com/play/xxxxx.html)作为独立的视频播放页面,并在主题的functions.php中添加
function MBT_rewrite_rule() {
Products
GG网络技术分享 2025-03-18 16:04 0
WordPress需要使用伪静态地址(mobantu.com/play/xxxxx.html)作为独立的视频播放页面,并在主题的functions.php中添加function MBT_rewrite_rule() {
global $wpdb;
$page_id = MBT_get_page_id_from_template('page-play.php');
$slug = get_post($page_id)->post_name;
add_rewrite_rule($slug.'/([^/]+).html$', 'index.php?page_id='.$page_id.'&v=$matches[1]','top');
}
add_action('init', 'MBT_rewrite_rule', 10, 0);
add_filter('query_vars', 'MBT_query_vars', 10, 1 );
function MBT_query_vars($public_query_vars) {
$public_query_vars[] = 'v';
return $public_query_vars;
}通过$wp_query->query独立播放页面['v']获取传入的 base64_encode 值。
Demand feedback