【问题标题】:Blank page after replying to a comment in Wordpress在 Wordpress 中回复评论后的空白页
【发布时间】:2016-01-18 19:45:38
【问题描述】:

我正在构建自己的 Wordpress 主题,但我的评论页面有问题。我可以发布 cmets,但是当我按下回复按钮回复我自己的评论时,我在发布回复时得到一个空白的 wp-cmets-post.php - 页面。我尝试了一些解决方案,但仍然无法正常工作。有任何想法吗?

这是我的 cmets.php 文件:

<?php
/**
 * The template for displaying Comments.
 *
 * The area of the page that contains comments and the comment form.
 *
 */
/*
 * If the current post is protected by a password and the visitor has not yet
 * entered the password we will return early without loading the comments.
 */
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    die('Please do not load this page directly. Thanks!');
if (post_password_required()) {
    ?>
    <p class="nocomments">Det här inlägget är lösenordsskyddat. Knappa in lösenordet för att se inlägget.</p>
    <?php
    return;
}
?>

    <div id="commentsbox" class="post">
        <?php if (have_comments()) : ?>
            <h3 id="comments">
                <?php comments_number('Inga kommentarer',
                    'En kommentar',
                    '% kommentarer'); ?>
                    än så länge.</h3>
                        <ol class="commentlist">
                            <?php wp_list_comments(array(
                                'avatar_size' => 70)); ?>
                        </ol>
                            <div class="comment-nav">
                                <div class="alignleft">
                                    <?php previous_comments_link() ?>
                                </div>
                                    <div class="alignright">
                                        <?php next_comments_link() ?>
                                    </div>
                            </div>
                                <?php else : ?>
                                    <?php if (comments_open()) : ?>
                                        <?php else :  ?>
                                            <p class="nocomments">Kommentarer är avstängda</p>
                                    <?php endif; ?>
                                <?php endif; ?> 
                                    <?php if (comments_open()) : ?>
                                    <div class="commentform_wrapper">
                                        <div class="post-info">
                                        </div>
                                            <div id="comment-form">    
                                                <?php $comment_args = array( 'title_reply'=>'Vänligen lämna dina synpunkter och kommentarer:',
                                                    'title_reply_to'    => __( 'Svara %s' ),
                                                    'cancel_reply_link' => __( 'Stäng svar' ),
                                                    'label_submit'=>'Skicka',
                                                    'reply_text' => 'Svara',
                                                        'fields' => apply_filters( 'comment_form_default_fields', array(
                                                            'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Namn' ) . '</label> ' . ( $req ? '<span>*</span>' : '' ) .
                                                            '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',   
                                                            'email'  => '<p class="comment-form-email">' .
                                                            '<label for="email">' . __( 'Mejl' ) . '</label> ' .
                                                            ( $req ? '<span>*</span>' : '' ) .
                                                            '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' />'.'</p>',
                                                            'url'    => '' ) ),
                                                            'comment_field' => '<p>' .
                                                            '<label for="comment">' . __( 'Kommentarer' ) . '</label>' .
                                                            '<textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>' .
                                                            '</p>',
                                                            'comment_notes_after' => '',
                                                );
                                                comment_form($comment_args); ?>
                                            </div>
        </div>
                                            <?php endif; ?>
    </div>

这是我的 single.php 文件,以备不时之需:

<?php 
/**
 * The Template for displaying all single posts.
 */
get_header('header3'); ?>

<section id="headerbox">
                    <header>
                        <h2 class="referensrubrik">Rubrik</h2>
                    </header>
                        <p class="referenstext">Text</p>
                </section>

<?php
        $post = $wp_query->post;
        while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

        <article id="blogpost2" id="post-<?php get_the_ID(); ?>" <?php post_class(); ?>>

        <h2><a href="<?php the_permalink(); ?>" title="Läs mer" class="blogpost"><?php the_title(); ?></a></h2>
        <h5><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></h5>
        <?php the_content(); ?>
        <hr>
        </article>

        <?php endwhile; ?>

        <?php if ($paged > 1) { ?>

        <nav id="nav-posts">
            <div class="prev"><?php next_posts_link('&laquo; Äldre inlägg'); ?></div>
            <div class="next"><?php previous_posts_link('Nyare inlägg &raquo;'); ?></div>
        </nav>

        <?php } else { ?>

        <nav id="nav-posts">
            <div class="prev"><?php next_posts_link('&laquo; Äldre inlägg'); ?></div>
        </nav>

        <?php } ?>

        <?php wp_reset_postdata(); ?>           
  <!--Start Comment box-->
                        <?php comments_template(); ?>
                        <!--End Comment box-->
<?php get_footer(); ?>

【问题讨论】:

    标签: php html wordpress


    【解决方案1】:

    大多数时候这是一个 (500) 错误:

    【讨论】:

    • 我收到“NetworkError: 500 Internal Server Error - wordpress.hem.net/wp-comments-post.php”,是的,这是 500 错误。但是我该怎么做呢?
    • 您是否设置了具有正确重写权限的 .htaccess 文件?
    • 哦,不,我不知道.. 从来没有听说过这样的文件。但我一定会调查的!
    • 当我没有登录并尝试发表评论或回复时,我只会得到一个空白页面。登录后就没问题了。
    【解决方案2】:

    这通常只发生在我在打开 PHP 标记的页面前面留下换行符或空格的错误时。虽然根据示例代码看起来并非如此 - 但我会三重检查您在打开之前没有回车或空格

    【讨论】:

    • 尝试开启 PHP 错误报告。这将有助于找到问题的根源。如果您无法弄清楚,请在您的问题中发布错误消息。下面是打开 PHP 错误报告的方法:stackoverflow.com/questions/1053424/…
    • 我得到的只是“未定义的变量:aria_req”,现在已修复。但仍然是空白页,即使在发布 cmets 时也是如此。
    • 也要检查你的部分。因此,请检查 header.php、footer.php,尤其是您的 cmets 模板,以查看文档顶部的换行符。
    【解决方案3】:

    问题解决了!因为我可以在以管理员身份登录时评论和回复 cmets,但不能以匿名访问者身份登录,所以我检查了我的讨论设置。每次有人发表评论时,他们都会向我发送一封电子邮件。不知何故,这失败了,当我取消选中该框时,问题就消失了。我需要查找电子邮件失败的原因,但现在我很高兴一切正常。

    【讨论】:

      【解决方案4】:

      其中一些问题来自您托管的服务器,您可以在 php 设置中更改它,

      post_max_size

      upload_max_filesize

      这将解决在wordpress上上传文件的许多问题

      【讨论】:

      • 我认为您的回答与问题无关。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-16
      • 1970-01-01
      相关资源
      最近更新 更多