提交评论导航到WordPress中的空白页

时间:2019-03-07 06:58:03

标签: wordpress custom-wordpress-pages

在我的single.php上,我具有注释的托管代码,当我提交评论时,它会转到带有URL“ https://mosquitojoefranchise.com/wp-comments-post.php”的空白页面。但是,如果我使用<?php comments_template(); ?>,则可以正常工作。我的代码如下:

<div id="comments">
                <ol>
            <?php
            $pId = $post->ID;
            $args = array(
                'number' => '5',
                'post_id' => $pId, // use post_id, not post_ID
            );
            $comments = get_comments($args);
            foreach($comments as $comment) :
            ?>                            
               <li>
                    <div class="avatar"><?php echo get_avatar( $comment, 68 ); ?></div>
                    <div class="comment_right">
                        <div class="comment_info">
                            <a href="<?php echo ($comment->comment_author_url); ?>"><?php echo($comment->comment_author);?></a> <span>&nbsp;</span><?php comment_date('F-j-Y'); ?>
                        </div>
                        <?php echo ($comment->comment_content);?><br>
                        <ul class="comment-links">
                            <li style="list-style:none !important;"><a aria-label="Reply to Mr WordPress" onclick="return addComment.moveForm( &quot;div-comment-1&quot;, &quot;1&quot;, &quot;respond&quot;, &quot;1&quot; )" href="<?php echo esc_url( get_permalink() ); ?>?replytocom=<?php echo ($comment->comment_ID); ?>#respond" class="comment-reply-link">Reply</a></li>
                    </ul></div>

                    <div class="clear"></div>                                        
               </li>
                <?php
                endforeach;
                ?>                               
            </ol>
            </div>
             <?php
        // If comments are open or we have at least one comment, load up the comment template.
        if ( comments_open() || get_comments_number() ) {
            //comments_template();
             //$file='/short-comments.php';
            //comments_template($file);

            if ('open' == $post->comment_status) : ?> 
                <div id="respond">                             
                <h3><?php comment_form_title( 'Post Comments', 'Post Comments to %s' ); ?>.</h3>                             
                <div class="cancel-comment-reply">
                    <small><?php cancel_comment_reply_link(); ?></small>
                </div>                             
                <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
                <p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a comment.</p>
                <?php else : ?>                             
                <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform" class="commentform">                             
                <?php if ( $user_ID ) : ?>                             
                <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out &raquo;</a></p>                             
                <?php else : ?>                             
                <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" placeholder="First Name" aria-label="First Name" />
                <input type="text" name="last_name" id="last_name" size="22" tabindex="2" placeholder="Last Name" aria-label="Last Name" />                             
                <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" placeholder="Email" aria-label="Email" />
                <input type="text" name="phone" id="phone"  size="22" tabindex="4" placeholder="Phone" aria-label="Phone" />                               
                <?php endif; ?>                            
                <textarea onBlur="if (this.value == '') this.value = 'Your Comment';" onFocus="if (this.value == 'Your Comment') this.value = '';" name="comment" id="comment" cols="100" rows="10" tabindex="4" aria-label="Your Comment">Your Comment</textarea> <br>                           

                <fieldset id="submit">
                    <legend style="display: none;">Comment Submit</legend>
                    <input name="submit" type="submit"  tabindex="5" value="Submit" class="btn btn-blue mahi" />
                </fieldset>    
                <input type="reset" value="Clear" class="btn">

                <?php comment_id_fields(); ?>

                <?php do_action('comment_form', $post->ID); ?>                             
                </form>                             
                <?php endif; // If registration required and not logged in ?>
                </div>
                <?php endif; // if you delete this the sky will fall on your head 
        }
    endwhile;
?>
            </div>

我不明白为什么要进入空白页,我已经采取了正确的表格操作,但仍然无法正常工作。请查看自定义代码并在这种情况下为我提供帮助。

0 个答案:

没有答案