Php 未在Wordpress上发布的评论-空白页

Php 未在Wordpress上发布的评论-空白页,php,mysql,wordpress,Php,Mysql,Wordpress,我正在处理一个主题(),我以前做过,但是如果你试图发表评论,你会被重定向到一个空白页面。这也发生在其他WP主题上,如Twenty16。以下是我在wp-comments-post.php上的代码: <?php /** * Handles Comment Post to WordPress and prevents duplicate comment posting. * * @package WordPress */ if ( 'POST' != $_SERVER['REQUEST

我正在处理一个主题(),我以前做过,但是如果你试图发表评论,你会被重定向到一个空白页面。这也发生在其他WP主题上,如Twenty16。以下是我在wp-comments-post.php上的代码:

<?php
/**
 * Handles Comment Post to WordPress and prevents duplicate comment posting.
 *
 * @package WordPress
 */

if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) {
    $protocol = $_SERVER['SERVER_PROTOCOL'];
    if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) {
        $protocol = 'HTTP/1.0';
    }

    header('Allow: POST');
    header("$protocol 405 Method Not Allowed");
    header('Content-Type: text/plain');
    exit;
}

/** Sets up the WordPress Environment. */
require( dirname(__FILE__) . '/wp-load.php' );

nocache_headers();

$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
if ( is_wp_error( $comment ) ) {
    $data = intval( $comment->get_error_data() );
    if ( ! empty( $data ) ) {
        wp_die( '<p>' . $comment->get_error_message() . '</p>', __( 'Comment Submission Failure' ), array( 'response' => $data, 'back_link' => true ) );
    } else {
        exit;
    }
}

$user = wp_get_current_user();

/**
 * Perform other actions when comment cookies are set.
 *
 * @since 3.4.0
 *
 * @param WP_Comment $comment Comment object.
 * @param WP_User    $user    User object. The user may not exist.
 */
do_action( 'set_comment_cookies', $comment, $user );

$location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : 
$_POST['redirect_to'] . '#comment-' . $comment->comment_ID;

/**
 * Filters the location URI to send the commenter after posting.
 *
 * @since 2.0.5
 *
 * @param string     $location The 'redirect_to' URI sent via $_POST.
 * @param WP_Comment $comment  Comment object.
 */
$location = apply_filters( 'comment_post_redirect', $location, $comment );

wp_safe_redirect( $location );
exit;

使用inspect manager查看问题页面时,可以看到问题是410代码错误。

410消失了

指示请求的资源在服务器上不再可用,并且将不再可用

此错误可能以多种方式发生

以下是一些检查点列表,可帮助您找到问题:

1.在wp-config.php中启用调试 并测试是否出现错误。你会很快修好的

2.重置永久链接 不知道为什么,但是有时候,Wordpress对一个旧的永久链接有一些奇怪的错误

我建议你去

  • 转到
    Settings->Permalinks
  • 开关永久对齐设置
  • 保存
  • 将其替换为当前配置
  • 再保存一次
3.禁用所有插件。 如果它能工作,一个接一个地激活插件,以便能够检测出是哪个插件造成了这个错误

4.刷新.htaccess 放置基本wordpress
.htaccess
。有时,一些插件会更改
.htaccess
中的规则,并引发许多重定向错误

5.无需修改即可将主题切换为默认主题 它可以帮助您了解主题中的自定义规则是否会创建此错误

6.从新安装重新上传wp管理员和wp包含 7.重置文件夹的写入/读取权限 你可以阅读帮助你知道你应该改变什么,它应该做什么


8.最终,创建新的WordPress安装。该网站返回HTTP 410状态码(401消失)。这通常与
有关。htaccess
您能帮我们发布吗?检查PHP错误日志,看看是否有什么奇怪的地方。重定向到哪里?@FMashiro
#在RewriteBase/WordPress/RewriteRule^index\.php$-[L]RewriteCond%{REQUEST_FILENAME}上启动WordPress RewriteEngine-f RewriteCond%{REQUEST_FILENAME}-重写规则/WordPress/DIXX.PHP[L]结尾WordPress < /Cord> @ Page,我被重定向到WP评论-PSP.php,但它是空白页。当我从前端查看它时,甚至还有一个空白源,所以可能它没有正确加载?另外,我找不到主机的PHP错误日志,很遗憾,我可能没有它可供使用。@Lilly如果您将上次的重写规则设置为:
RewriteRule该怎么办/index.php[L]
     // Enable WP_DEBUG mode
     define( 'WP_DEBUG', true );
     
     // Enable Debug logging to the /wp-content/debug.log file
     define( 'WP_DEBUG_LOG', true );

     // Enable display of errors and warnings 
     define( 'WP_DEBUG_DISPLAY', true );
     @ini_set( 'display_errors', 1 );