cpkid2
02-02-2010, 09:07 PM
I'm building this site on Wordpress and I'm trying to make the comments numbered for the comments section by setting a variable and using $commentcount++ . You can see what I mean here:
As you can see, all of the numbers are "1" when they should be adding up as new comments get submitted. What am I doing wrong?
Here's what I have at the top of comments.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 ( post_password_required() ) { ?>
<p class="nocomments">This post is password protected. Enter the password to view comments.</p>
<?php
return;
}
$commentcount = 1;
?>
Here's what I put in my functions.php file:
function format_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; $commentcount = 1;?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<span class="comment-number">
<?php echo $commentcount++;?>
</span>
<div class="comment-avatar">
<?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
</div>
<div class="comment-text">
<div class="comment-author">
<?php printf(__('<span>%s</span>'), get_comment_author_link()) ?>
</div>
<div class="comment-date">
<?php echo get_comment_date(); ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?></em>
<?php endif; ?>
<?php edit_comment_link(__('(Edit)'),' ','') ?>
<?php comment_text() ?>
</div>
<?php
}
Any help would be appreciated. Thanks in advance.
As you can see, all of the numbers are "1" when they should be adding up as new comments get submitted. What am I doing wrong?
Here's what I have at the top of comments.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 ( post_password_required() ) { ?>
<p class="nocomments">This post is password protected. Enter the password to view comments.</p>
<?php
return;
}
$commentcount = 1;
?>
Here's what I put in my functions.php file:
function format_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; $commentcount = 1;?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<span class="comment-number">
<?php echo $commentcount++;?>
</span>
<div class="comment-avatar">
<?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
</div>
<div class="comment-text">
<div class="comment-author">
<?php printf(__('<span>%s</span>'), get_comment_author_link()) ?>
</div>
<div class="comment-date">
<?php echo get_comment_date(); ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?></em>
<?php endif; ?>
<?php edit_comment_link(__('(Edit)'),' ','') ?>
<?php comment_text() ?>
</div>
<?php
}
Any help would be appreciated. Thanks in advance.