function prefix_register_query_var( $vars ) {
$vars[] = \'eid\';
return $vars;
}
add_filter( \'query_vars\', \'prefix_register_query_var\' );
function prefix_rewrite_templates() {
if ( get_query_var( \'eid\' ) ) {
add_filter( \'template_include\', function() {
return get_template_directory() . \'/events-single.php\';
});
}
}
add_action( \'template_redirect\', \'prefix_rewrite_templates\' );
添加
$var
指向循环中的URL:
$url = add_query_arg( array(
\'eid\' => get_the_ID(),
) );