0
votes

This is my first post here, I've tried to ensure it's in line with the posting guidelines. Apologies in advance if I've missed anything!

I'm having trouble with my website's comment functionality. The site is here: http://chrislee.is/thinking-about. The number of comments is showing below each post, as well as a prompt to submit your own, but the content of the comments is not showing. For a specific post where there is 1 comment that is not showing, see here: http://chrislee.is/thinking-about/saying-yes-more/

The theme is heavily adapted from Blogum, and represents my first attempt at building a custom theme. I've had a policy of testing and saving every change individually to ensure I can retrace my steps if something goes wrong, but somewhere along the line I've messed up the comments.

Here are the comments and single single post (single.php) php files, respectively:

<?php if ( comments_open() ) : ?>
<div id="comments">
    <?php if ( post_password_required() ) : ?>
                    <p class="nopassword"><?php _e('This post is password protected. Enter the password to view any comments.'); ?></p>
                </div><!-- #comments -->
    <?php
            /* Stop the rest of comments.php from being processed,
             * but don't kill the script entirely -- we still have
             * to fully load the template.
             */
            return;
        endif;
    ?>

    <?php
        // You can start editing here -- including this comment!
    ?>

        <div class="comments_heading clear">
            <div class="comment_qty"><?php
                printf( _n('1 comment', '%1$s comments', get_comments_number()),
                number_format_i18n( get_comments_number() ), '' );
                ?></div>
            <div class="add_comment"><a href="#respond">Submit yours</a></div>
        </div>

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

        <div class="comment_list">
            <ol>
            <?php
                wp_list_comments(array('callback' => 'commentlist'));
            ?>
            </ol>
        </div>

    <?php endif; // end have_comments() ?>

    <?php if ('open' == $post->comment_status) : ?>

    <div id="respond" class="clear">
        <div class="respond_meta">Submit comment</div>
        <div class="comment_form">

        <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
            <p class="comment_message">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" onSubmit="return checkFields();">

                <?php if ( $user_ID ) : ?>

                    <p class="comment_message">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 : ?>
                    <div class="user_data">
                        <p><input id="author" type="text" name="author" class="focus" onfocus="if(this.value=='Name') this.value='';" onblur="if(this.value=='') this.value='Name';" value="Name" tabindex="1" /></p>
                        <p><input id="email" type="text" name="email" class="focus" onfocus="if(this.value=='Email') this.value='';" onblur="if(this.value=='') this.value='Email';" value="Email" tabindex="2" /></p>
                        <p><input id="url" type="text" name="url" class="focus" onfocus="if(this.value=='Website') this.value='';" onblur="if(this.value=='') this.value='Website';" value="Website" tabindex="3" /></p>
                    </div>
                <?php endif; ?>

                <!--<p class="comment_message"><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->

                <div class="comment_field">
                    <textarea name="comment" class="focus" id="comment" cols="50" rows="10" tabindex="4" onfocus="if(this.innerHTML=='Comment') this.innerHTML='';">Comment</textarea>
                </div>

                <p class="comment_submit"><input name="submit" type="submit" id="submit" tabindex="5" value="Submit" />
                <?php comment_id_fields(); ?>
                </p>
                <?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 ?>

    </div>

</div>
<?php endif; // end ! comments_open() ?>
<!-- #comments -->

And the comments section of the Single.php file:

 <?php
        // You can start editing here -- including this comment!
    ?>

        <div class="comments_heading clear">
            <div class="comment_qty"><?php
                printf( _n('1 comment', '%1$s comments', get_comments_number()),
                number_format_i18n( get_comments_number() ), '' );
                ?></div>
            <div class="add_comment"><a href="#respond">Submit yours</a></div>
        </div>

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

        <div class="comment_list">
            <ol>
            <?php
                wp_list_comments(array('callback' => 'commentlist'));
            ?>
            </ol>
        </div>

    <?php endif; // end have_comments() ?>

    <?php if ('open' == $post->comment_status) : ?>

    <div id="respond" class="clear">
        <div class="respond_meta">Submit comment</div>
        <div class="comment_form">

        <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
            <p class="comment_message">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" onSubmit="return checkFields();">

                <?php if ( $user_ID ) : ?>

                    <p class="comment_message">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 : ?>
                    <div class="user_data">
                        <p><input id="author" type="text" name="author" class="focus" onfocus="if(this.value=='Name') this.value='';" onblur="if(this.value=='') this.value='Name';" value="Name" tabindex="1" /></p>
                        <p><input id="email" type="text" name="email" class="focus" onfocus="if(this.value=='Email') this.value='';" onblur="if(this.value=='') this.value='Email';" value="Email" tabindex="2" /></p>
                        <p><input id="url" type="text" name="url" class="focus" onfocus="if(this.value=='Website') this.value='';" onblur="if(this.value=='') this.value='Website';" value="Website" tabindex="3" /></p>
                    </div>
                <?php endif; ?>

                <!--<p class="comment_message"><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->

                <div class="comment_field">
                    <textarea name="comment" class="focus" id="comment" cols="50" rows="10" tabindex="4" onfocus="if(this.innerHTML=='Comment') this.innerHTML='';">Comment</textarea>
                </div>

                <p class="comment_submit"><input name="submit" type="submit" id="submit" tabindex="5" value="Submit" />
                <?php comment_id_fields(); ?>
                </p>
                <?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 ?>

    </div>

</div>
<?php endif; // end ! comments_open() ?>
<!-- #comments -->
    <?php endwhile; ?>
<?php endif; ?>

</div>
 </div>
        </div>



<?php get_sidebar(); ?>


<?php get_footer(); ?>

Thank you in advance for any insights you're able to give :)

2

2 Answers

0
votes

Have you read the Display Comments for a Specific Page/Post on the wordpress site. it seems to suggest that you need to pass an array of comments to the 'wp_list_comments'.

wp_list_comments(array('callback' => 'commentlist'));

I'd stick one or two var_dumps() in and around here, so you can see what data is available.

0
votes

If I were to hazard a guess, your problem is here:

wp_list_comments(array('callback' => 'commentlist'));

From the Codex:

'callback'
( callback ) The name of a custom function to use to open and display each comment. Using this will make your custom function get called to display each comment, bypassing all internal WordPress functionality in this respect. Use to customize comments display for extreme changes to the HTML layout. Note that your callback must include the opening <div>, <ol>, or <ul> tag (corresponding with the style parameter), but not the closing tags. WordPress will supply the closing tag automatically, or you can use end-callback to override this default. The callback is separate from the end-callback to facilitate hierarchical comments. Use with caution.

If no comments are showing up, my guess is that you probably don't have a function named 'commentlist' defined anywhere.

Try changing it to this:

wp_list_comments(array('style'=>'ol', 'type'=>'comment'));