由于自定义Comments.php文件,无法连接评论

时间:2011-01-30 作者:Ayaz Malik

嘿,我试着使用wordpress的线程评论功能,但由于自定义主题,所以没有成功。我尝试了wp线程评论插件,它的工作方式很有魅力,但不幸的是,它与FV社区新闻插件有冲突,它在社区新闻区域/小部件上显示了一个回复按钮。

所以我试着手动操作。。。没有运气。谁能给我提个建议或者告诉我什么地方我可以得到一些数据来解决这个问题吗。

我的wordpress版本是3.0.4cheers

当前注释。php

<?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 (!empty($post->post_password)) { // if there\'s a password
        if ($_COOKIE[\'wp-postpass_\' . COOKIEHASH] != $post->post_password) {  // and it doesn\'t match the cookie
            ?>

            <p>This post is password protected. Enter the password to view comments.</p>

            <?php
            return;
        }
    }

    /* This variable is for alternating comment background */
    $oddcomment = \'alt\';
?>
<?php if ( $comments ) : ?>
<!-- You can start editing here. -->

            <?php $urlHome = get_bloginfo(\'template_directory\'); ?>
                        <div class="box post-comments" id="comments">
                <div class="content">
                    <h4>Awesome Comments!</h4>

                    <?php foreach ($comments as $comment) : ?>
                   <?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == \'comment\') { ?>
                     <div id="comment-<?php comment_ID() ?>" class="fl ar">

                        <div class="pic"><?php echo get_avatar( $comment, 80, $default = $urlHome . \'/images/default_avatar_visitor.gif\' ); ?></div>
                        <div class="comm-name"><a href="<?php comment_author_url(); ?>" target="_blank" rel="nofollow"><?php comment_author(); ?></a></div>
                        <div class="comm-date"><small><em><?php the_time(\'m.d.y\') ?></em></small></div>
                     </div>
                     <div class="fr">
                       <div class="box2 <?php echo $oddcomment; ?>">
                         <?php comment_text() ?>
                       </div><!--/box2 -->
                     </div>   <div class="fix"></div>

                        <?php $oddcomment = ( empty( $oddcomment ) ) ? \'alt\' : \'\'; ?> 
                        <?php } /* End of is_comment statement */ ?>
                                    <?php endforeach; // end for each comment ?>

                </div> </div>
               <div class="box">
               <div class="content">
<h3 id="trackbacks">Trackbacks</h3>
<ol class="trackbacksol">
    <?php //Displays trackbacks only
    foreach ($comments as $comment) : ?>
        <?php $comment_type = get_comment_type(); ?>
        <?php if($comment_type != \'comment\') { ?>
        <li><?php comment_author_link() ?></li>
    <?php }  endforeach; ?>
</ol>
</div></div>
<?php endif; ?>
<?php if (\'open\' == $post->comment_status) : ?> 
            <div id="respond" class="box post-comments">
                <div class="content">
                    <h4>Leave Your Response</h2>

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

                    <div class="fl">
                        <?php if ( is_user_logged_in() ) {?>
                        <div class="pic"><img src="<?php bloginfo(\'template_directory\'); ?>/images/default_avatar_visitor.gif" alt="" /></div>
                        <?  } else { ?>
                         <p>Your Name: </p>
                        <p style="margin-top:9px;">Your Email: </p>
                        <p style="margin-top:12px;">Website: </p>
                        <p style="margin-top:15px;">Comments: </p> <? } ?>
                    </div>
                    <div class="fr">
                        <form action="<?php echo get_option(\'siteurl\'); ?>/wp-comments-post.php" method="post" id="commentform">
                            <fieldset class="message">
                            <?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 get_option(\'siteurl\'); ?>/wp-login.php?action=logout" title="Log out of this account">Log out &raquo;</a></p>
                            <?php else : ?>
                            <div>
                                <input name="author" id="author" type="text" value="" />
                            </div>
                            <div>
                                <input name="email" id="email" type="text" value="" />
                            </div>
                            <div>
                                <input name="url" id="url" type="text" value="" />
                            </div>
                            <?php endif; ?>
                            <div class="textarea">
                                <textarea name="comment" id="comment" cols="" rows=""></textarea>
                            </div>
                            <div class="submit">
                                <input name="submit" id="submit" type="image" src="<?php bloginfo(\'template_directory\'); ?>/images/btn-submit.gif" value="Send" class="btn"  />
                            </div>
                            <div class="notice">* Name, Email, Comment are Required</div>
                            <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
                            <?php do_action(\'comment_form\', $post->ID); ?>
                            </fieldset>
                        </form>
                        <?php endif; // If registration required and not logged in ?>
                    </div>
                    <div class="fix"></div>
                </div>
                <!--/content -->
            </div>
            <!--/box -->
            <?php endif; // if you delete this the sky will fall on your head ?>

1 个回复
最合适的回答,由SO网友:Rarst 整理而成

因为主题很旧或者只是以不兼容的方式编码,所以它不起作用吗?

法典中有一条可能与以下内容相关:Migrating Plugins and Themes to 2.7/Enhanced Comment Display.

否则,我会看看一些现代主题(比如210),看看它是如何为当前的WordPress版本正确编码的。

结束