1

I'm building a Wordpress theme of my own, and having a problem with my comment-page. I can post comments, but when I press the reply-button to reply to my own comment, I get a blank wp-comments-post.php - page when posting my reply. I've tried some solutions, but it's still not working. Any ideas?

This is my comments.php file :

<?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>

And this is my single.php file, in case you need it:

<?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(); ?>
j08691
  • 204,283
  • 31
  • 260
  • 272
Jessie.J
  • 85
  • 2
  • 9

4 Answers4

0

Most of the time this is an (500) error:

schellingerht
  • 5,726
  • 2
  • 28
  • 56
  • I get "NetworkError: 500 Internal Server Error - http://wordpress.hem.net/wp-comments-post.php", så yes, it's a 500 error. But how do I proceed with this? – Jessie.J Jan 18 '16 at 20:19
  • Do you have an .htaccess file set up with the correct rewrite permissions? – Korgrue Jan 18 '16 at 20:22
  • Oh, no I don't.. Never heard about a file called like that. But I sure will look into it! – Jessie.J Jan 18 '16 at 20:39
  • I only get a blank page when I'm not logged in and trying to post a comment or a reply. It's no problem when I'm logged in. – Jessie.J Jan 18 '16 at 20:45
0

This typically only happens to me when I make a mistake with either leaving a line break or space in front of the pages opening PHP tag. While it does not looks not be the case based on the example code - but I would triple check that you have no carriage returns or spaces before the opening

Korgrue
  • 3,430
  • 1
  • 13
  • 20
  • try turning on PHP error reporting. That will help to get to the bottom of the issue. Post the error message in your questions if you cant figure it out. Here is how to turn on PHP error reporting: http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display – SG_Rowin Jan 18 '16 at 19:59
  • All I got was "Undefined variable: aria_req" and that's fixed now. But still a blank page, even when posting comments. – Jessie.J Jan 18 '16 at 20:09
  • Check your partials as well. So check the header.php, footer.php, and especially your comments template for line carriage returns at the top of the document. – Korgrue Jan 18 '16 at 20:19
0

Problem solved! Because I could comment and reply comments when logged in as admin, but not as an anonymous visitor, I cheched my discussion settings. They were set to send me an email every time someone posted a comment. Somehow this is failing and when I uncheched the box the problem was gone. I need to look up why the email is failing, but for now I'm just happy that everything is working as it should.

Jessie.J
  • 85
  • 2
  • 9
0

Some of this problem are from the server where you are hosted, you may me able to change it on the php settings,

post_max_size

, and the

upload_max_filesize

this will the solution of many problem uploading files on wordpress