Comment form does not appear in theme

Asked

Viewed 898 times

9

I am creating a new theme for Wordpress and can not make appear the file comments form comments.php. The other related elements (already saved comments, amount of comments, etc.) usually appear, but the form itself does not appear even if I leave comments open normally on blog.

The code is this:

<?php
   if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
   die ('Por favor não carregue esta página diretamente. Valeu!');

   if (post_password_required()) { ?>
       <p class="nocomments">Este artigo está protegido por senha.</p>
   <?php
       return;
   }
?>
<div class="comentarios row post-texto">
    <?php if ( have_comments() ) : ?>
        <ul class="commentlist">
            <?php wp_list_comments('avatar_size=64&type=comment'); ?>
        </ul>
        <?php if ($wp_query->max_num_pages > 1) : ?>
            <div class="pagination">
                <ul>
                    <li class="older"><?php previous_comments_link('Anteriores'); ?></li>
                    <li class="newer"><?php next_comments_link('Novos'); ?></li>
                </ul>
            </div>
        <?php endif; ?>
        <!-- Caixa de Comentários -->
    <?php endif; ?>
    <?php if ( comments_open() ) : ?>
        <form name="comment" id="formcomentario" method="POST" action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php">
            <?php if ( $user_ID ) : ?>
            <div class="small-12 columns">
            <h5><?php comments_number('Seja o primeiro a comentar!', '1 Comentário. Participe da discussão!', '% Comentários. Participe da discussão!' );?></h5>
            <p>Autenticado como <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(); ?>" title="Encerrar sessão">[ENCERRAR SESSÃO]</a></p>
            </div>
        <?php else: ?>
        <div class="small-12 columns">
            <label>Seu nome (obrigatório)
                <input class="comentario-nome" type="text" value="<?php echo $comment_author; ?>" />
            </label>
        </div>
        <div class="small-6 columns">
            <label>Seu e-mail (obrigatório)
                <input class="comentario-email" type="text" value="<?php echo $comment_author; ?>" />
            </label>
        </div>
        <div class="small-6 columns">
            <label>Seu site (caso haja)
                <input class="comentario-url" type="text" value="<?php echo $comment_author_url; ?>" />
            </label>
        </div>
        <div class="small-12 columns">
            <label>Seu comentário
                <textarea class="comentario-texto"></textarea>
            </label>
        </div>
        <div class="small-12 columns">
            <a href="#" class="button expand botao-comentario">Enviar comentário</a>
        </div>
        <?php comment_id_fields(); ?>
        <?php do_action('comment_form', $post->ID); ?>
    </form>
    <p><?php cancel_comment_reply_link('Cancelar resposta'); ?></p>
        <?php endif; ?>
    <?php else: ?>
        <p>Os comentários estão fechados.</p>
<?php endif; ?>

What is the cause of this problem?

  • you have already checked if the settings in the panel is enabled the comment option. If you didn’t make Settings >> Discussion >> Select Comment Checkbox Settings.

  • @Gabriel This option is already activated in my Wordpress installation. I even deactivated and reactivated to confirm and the comments continue not appearing. I also individually enabled and disabled pro post I’m using for testing and nothing happened.

  • I was able to solve it. I decided not to write the form in my hand anymore and <?php comment_form(); ?>

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.