- 状态
- 已解决
- 报告针对
- WPForms Multilingual 0.3.6
- 解决于
- WPForms Multilingual 0.4.0
- 相关插件/主题
- WPForms
- 主题标签
- Compatibility
问题概述
如果您使用 WPForms 及其 WPForms Form Pages 附加组件,在采用自定义固定链接结构(例如 /artikel/%postname%/)访问次要语言的表单页面时,可能会遇到 404 错误。
临时解决方法
请确保在继续操作之前对您的网站进行完整备份。
- 打开 …/wp-content/plugins/wpforms-form-pages/src/Frontend.php 文件。
- 找到第 78 行。
- 替换:
$request = ! empty( $request ) ? sanitize_key( wp_parse_url( $request, PHP_URL_PATH ) ) : '';
- 替换为:
if ( ! empty( $request ) ) { // Parse the URL to get the path component $path = wp_parse_url( $request, PHP_URL_PATH ); // Use a regular expression to remove the language segment (e.g., "/en/") from the path // This pattern assumes the language code is always two characters and follows the first "/" $path = preg_replace( '#^/([a-zA-Z]{2})/#', '/', $path ); // Sanitize the resulting path $request = sanitize_key( $path ); } else { $request = ''; }