1

快速提问:

是否可以在 Wordpress 的多个页面中使用相同的评论框?

我想在 4-5 个不同的页面上显示完全相同的评论。

可能吗?

提前致谢!

编辑:我添加了下面的代码(它是葡萄牙语),我尝试在每个帖子的基础上插入,但我相信我搞砸了为两个帖子设置正确的帖子 ID 应该评论与其他页面相关,然后在其他页面上对其进行解析

<?php
// Do not delete these lines
    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">Este artigo está protegido por password. Insira-a para ver os comentários.</p>
    <?php
        return;
    }
?>

<div id="comments">
    <h3><?php comments_number('0 Comentários', '1 Comentário', '% Comentários' );?></h3>

    <?php if ( have_comments() ) : ?>

        <ol class="commentlist">
            <?php
                //Gather comments for a specific page/post 
                $comments = get_comments(array(
                    'post_id' => 156,
                    'status' => 'approve' //Change this to the type of comments to be displayed
                ));

                //Display the list of comments
                wp_list_comments(array(
                    'per_page' => 10, //Allow comment pagination
                    'reverse_top_level' => false //Show the latest comments at the top of the list
                ), $comments);
            ?>
        </ol>

    </div>

    <?php endif; ?>

    <?php if ( comments_open() ) : ?>

    <div id="respond">
            <h3>Deixe o seu comentário!</h3>

            <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
            <fieldset>
                <?php if ( $user_ID ) : ?>

                <p>Autentificado 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="Sair desta conta">Sair desta conta &raquo;</a></p>

                <?php else : ?>

                <label for="author">Nome:</label>
                <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" />

                <label for="email">Email:</label>
                <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" />

                <label for="url">Website:</label>
                <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" />

                <?php endif; ?>

                <label for="comment">Mensagem:</label>
                <textarea name="comment" id="comment" rows="" cols=""></textarea>

                <input type="submit" class="commentsubmit" value="Enviar Comentário" />

                <?php comment_id_fields(); ?>
                <?php do_action('comment_form', $post->ID); ?>
            </fieldset>
        </form>
        <p class="cancel"><?php cancel_comment_reply_link('Cancelar Resposta'); ?></p>
        </div>
     <?php else : ?>
        <h3>Os comentários estão fechados.</h3>
<?php endif; ?>
</div>
4

1 回答 1

0

对的,这是可能的。请参阅法典wp_list_comments()-

<ol class="commentlist">
    <?php
        //Gather comments for a specific page/post 
        $comments = get_comments(array(
            'post_id' => XXX,
            'status' => 'approve' //Change this to the type of comments to be displayed
        ));

        //Display the list of comments
        wp_list_comments(array(
            'per_page' => 10, //Allow comment pagination
            'reverse_top_level' => false //Show the latest comments at the top of the list
        ), $comments);
    ?>
</ol>
于 2012-11-22T12:57:54.267 回答