• Resolved dttn

    (@dttn)


    This is what’s in the theme I’m using
    <?php wp_list_comments('callback=custom_comments'); ?>

    I need the comments to order from newest to old.

    This is the custom_comments function

    // custom comments
    function custom_comments($comment, $args, $depth) {
    	$GLOBALS['comment'] = $comment;
    	global $commentcount;
    	if(!$commentcount) {
    		$commentcount = 0;
    	}
    ?>
    
    	<li class="<?php echo $oddcomment; if($comment->comment_type == 'pingback' || $comment->comment_type == 'trackback') {echo ' trackback';} else if($comment->comment_author_email == get_the_author_email()) {echo ' admincomment';} else {echo ' regularcomment';} ?>" id="comment-<?php comment_ID() ?>">
    
    		<div class="authorinfo">
    			<?php
    				if($comment->comment_type != 'pingback' && $comment->comment_type != 'trackback') {
    					// Support avatar for WordPress 2.5 or higher
    					if (function_exists('get_avatar') && get_option('show_avatars')) {
    						echo '<div class="authoravatar">';
    						echo get_avatar($comment, 24);
    						echo '</div>';
    					// Support Gravatar for WordPress 2.3.3 or lower
    					} else if (function_exists('gravatar')) {
    						echo '<div class="authoravatar"><img class="avatar" src="';
    						gravatar("G", 24);
    						echo '" alt="avatar" /></div>';
    					}
    				}
    			?>
    			<div class="authortext">
    				<?php if (get_comment_author_url()) : ?>
    					<a class="authorname" id="commentauthor-<?php comment_ID() ?>" href="<?php comment_author_url() ?>">
    				<?php else : ?>
    					<span class="authorname" id="commentauthor-<?php comment_ID() ?>">
    				<?php endif; ?>
    
    				<?php comment_author() ?>
    
    				<?php if(get_comment_author_url()) : ?>
    					</a>
    				<?php else : ?>
    					</span>
    				<?php endif; ?>
    				<div class="date"><? printf( __('%1$s at %2$s', 'blocks2'), get_comment_time(__('F jS, Y', 'blocks2')), get_comment_time(__('H:i', 'blocks2')) ); ?></div>
    			</div>
    			<div class="count">
    				<?php if($comment->comment_type != 'pingback' && $comment->comment_type != 'trackback') : ?>
    					<a href="javascript:void(0);" onclick="MGJS_CMT.reply('commentauthor-<?php comment_ID() ?>', 'comment-<?php comment_ID() ?>', 'comment');"><?php _e('Reply', 'blocks2'); ?></a> |
    					<a href="javascript:void(0);" onclick="MGJS_CMT.quote('commentauthor-<?php comment_ID() ?>', 'comment-<?php comment_ID() ?>', 'commentbody-<?php comment_ID() ?>', 'comment');"><?php _e('Quote', 'blocks2'); ?></a> |
    				<?php endif; ?>
    				<?php edit_comment_link(__('Edit', 'blocks2'), '', ' | '); ?>
    				<a href="#comment-<?php comment_ID() ?>"><?php printf('#%1$s', ++$commentcount); ?></a>
    			</div>
    			<div class="fixed"></div>
    		</div>
    
    		<?php if($comment->comment_type != 'pingback' && $comment->comment_type != 'trackback') : ?>
    			<div class="content">
    				<?php if ($comment->comment_approved == '0') : ?>
    					<p><small>Your comment is awaiting moderation.</small></p>
    				<?php endif; ?>
    
    				<div id="commentbody-<?php comment_ID() ?>">
    					<?php comment_text() ?>
    				</div>
    			</div>
    		<?php endif; ?>
    
    		<div class="fixed"></div>
    	</li>
    
    <?php
    	if ($oddcomment == 'oddcomment') {
    		$oddcomment = '';
    	} else {
    		$oddcomment = 'oddcomment';
    	}
    }
    ?>

    Any help is appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Did you look at the
    reverse_top_level and reverse_children parameters for wp_list_comments?

    Something like:

    ?php wp_list_comments('reverse_top_level=DESC&callback=custom_comments'); ?>

    That also looks like that can be controlled via the Comments should be displayed with the [older/newer] comments at the top of each page setting in Administration > Settings > Discussion

    Thread Starter dttn

    (@dttn)

    Thanks! I wasn’t aware that there’s an option for that in the admin cp.

    Thanks again.

    This doesn’t invert the Comment Numbers!

    Is there an option to change this also?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I change the order of comments with wp_list_comments’ is closed to new replies.