0815

Du musst dich anmelden um Beiträge und Themen zu erstellen. Einloggen · Registrieren

New WordPress-2.7 Comments Loop

Due to the changes made to comment-related functions in WordPress 2.7, you will need to upgrade your comments template in order accomodate for the new functionality. The major changes are the new wp_list_comments() function and the next/previous_comments_link()functions. Here is an example comments.php loop to get you started:

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

	<h4><?php comments_number('No Comments', 'One Comment', '% Comments' );?></h4>
	<ul class="commentlist">
		<?php wp_list_comments(); ?>
	</ul>
	<div class="navigation">
		<div class="alignleft"><?php previous_comments_link(); ?></div>
		<div class="alignright"><?php next_comments_link(); ?></div>
	</div>

<?php else : // if there are no comments so far ?>

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

		<p>Comments are open, but there are no comments.</p>

	<?php else : ?>

		<p>Comments are closed, and there are no comments.</p>

	<?php endif; ?>

<?php endif; ?>

As you can see, we are now using the wp_list_comments() function as the method by which our individual comments are displayed. This function wraps each comment with a set of <li>elements, but this may be changed via customized parameters. We are also using the next/previous_comments_link() functions to accommodate the new built-in paged comments feature.

Source: Digging into WordPress




0