Hallo Leute! Seit ich eingebaut habe, dass bei den Kommentaren Avatare angezeigt werden, gibt es folgendes Problem: Wenn ich als Autor auf einen Kommentar antworte, steht mein Kommentar logischerweise unter dem beantworteten Kommentar. Beantworte ich jedoch einen weiteren Kommentar, steht mein Kommentar nicht unter dem beantworteten Kommentar, sondern alle meine Kommentare stehen untereinander. Ich hoffe das ist verständlich formuliert. Es sieht also etwa so aus:
Kommentar A
Kommentar B
---Antwort auf Kommentar A
---Antwort auf Kommentar B
Ich finde einfach den Fehler nicht. Ich hoffe ihr könnt mir helfen:
PHP
<?php if(!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) : ?>
<?php die('Die Datei "comments.php" kann nicht direkt aufgerufen werden.'); ?>
<?php endif; ?>
<div id="kommentare">
<h4>kommentare</h4>
<?php foreach ($comments as $comment) : ?>
<div class="<?php if ($comment->comment_author_email == "max@mustermann.de") echo 'author'; else echo $oddcomment; ?> comment" id="comment-<?php comment_ID() ?>">
<?php echo get_avatar( $comment, $size = '60', $default ='' ); ?>
<small class="commentmetadata"><?php comment_author_link() ?> Ι am <?php comment_date('j. F Y') ?> um <?php comment_time('H:i') ?> Uhr</small>
<?php comment_text() ?>
<?php if ($comment->comment_approved == '0') : ?>
<br />
<p><strong>Dein Kommentar muss noch freigegeben werden.</strong></p>
<?php endif; ?>
</div>
<?php endforeach; /* end for each comment */ ?>
</div><!-- kommentare -->
<div id="kommentar_formular">
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<p>
<label for="author">Name</label>
<br /><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" tabindex="1" />
</p>
<p>
<label for="email">Email</label>
<br /><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" tabindex="2" />
</p>
<p>
<label for="url">Webseite</label>
<br /><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" tabindex="3" />
</p>
<p>
Kommentar
<textarea name="comment" id="comment" rows="10" tabindex="4"></textarea>
</p>
<p>
<input class="comment_button" name="submit" type="submit" id="submit" tabindex="5" value="Kommentar abschicken" />
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
</p>
<?php do_action('comment_form', $post->ID); ?>
</form>
</div> <!-- kommentar_formular -->
Alles anzeigen