Bis jetzt haben wir uns mit der comments.php des default Themes zufrieden gegeben. Im Prinzip ist das auch gar nicht mal so schlecht, mit der Einschränkung, dass es Englisch ist. Man hat also die Wahl es mit CSS zu gestalten, womit ganz schöne Ergebnisse möglich sind, oder ein eigenes zu programmieren. Obwohl ich normalerweise kein Freund davon bin Altes abzuändern, zahlt es sich bei der comments.php doch aus. Es steckt ziemlich viel Logik dahinter was hier angezeigt wird. (Kommentieren erlaubt, Kommentieren nur wenn eingeloggt, usw.) Diese Logik sollte man aus der comments.php übernehmen.
In dieser Datei finden sich eine Menge _e() und __() Funktionen. Hier wird jeweils eine englische Phrase angegeben und im 2. Parameter (kubrick) das Übersetzungsfile, wo Wordpress die anderssprachigen Übersetzungen findet. Nachdem wir aber ein rein Deutsches Theme machen kann man hier fixe Texte eingeben.
Nachdem ich die Logik und den Aufbau der comments.php recht sinnvoll finde ersetze ich nur die -E und __ Funktionen. Die Ausgabe der Comments adaptiere ich etwas und das Styling erfolgt in der styles.css
Fertig.
Zum Ansehen hier die comments.php. Augrund der vielen Logik leider etwas unübersichtlich !
<?php // Do not delete these lines if (isset($_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">Bitte Passwort eingeben.</p> <?php return; } ?> <!-- You can start editing here. --> <div id="commentwrap"> <?php if ( have_comments() ) : ?> <h3 id="comments"><?php comments_number("keine Kommentare", "Ein Kommentar", "% Kommentare");?> <?php printf("zu", the_title('', '', false)); ?></h3> <div class="navigation"> <div class="alignleft"><?php previous_comments_link() ?></div> <div class="alignright"><?php next_comments_link() ?></div> </div> <ol class="commentlist"> <?php $oddcomment=""; foreach ($comments as $comment) : ?> <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"> <?php if ($oddcomment=="") $oddcomment='class="oddcomment"'; else $oddcomment=""; ?> <div class="quote"><?php comment_text() ?></div> <?php if ($comment->comment_approved == '0') : ?> <em>Your comment is awaiting moderation.</em> <?php endif; ?> </li> <div class="commentmeta"><?php comment_author_link() ?> - <a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> - <?php comment_time() ?> <?php edit_comment_link('edit',' ',''); ?></a></div> <?php ?> <?php endforeach; /* end for each comment */ ?> </ol> <div class="navigation"> <div class="alignleft"><?php previous_comments_link() ?></div> <div class="alignright"><?php next_comments_link() ?></div> </div> <?php else : // this is displayed if there are no comments so far ?> <?php if ( comments_open() ) : ?> <!-- If comments are open, but there are no comments. --> <?php else : // comments are closed ?> <!-- If comments are closed. --> <p class="nocomments">Kommentare nicht möglich</p> <?php endif; ?> <?php endif; ?> <?php if ( comments_open() ) : ?> <div id="respond"> <h6><?php comment_form_title( "Senf dazugeben", "Gib doch deinen Senf zu %s " ); ?></h6> <div id="cancel-comment-reply"> <?php cancel_comment_reply_link() ?> </div> <?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?> <p><?php printf('Du mußt <a href="%s">eingeloggt</a> sein um zu Kommentieren', wp_login_url( get_permalink() )); ?></p> <?php else : ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> <?php if ( is_user_logged_in() ) : ?> <p><?php printf('Eingeloggt als <a href="%1$s">%2$s</a>.', get_option('siteurl') . '/wp-admin/profile.php', $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="ausloggen">Ausloggen</a></p> <?php else : ?> <p><input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> /> <label for="author"><?php _e('Name', 'kubrick'); ?> <?php if ($req) echo("das muss leider sein"); ?></label></p> <p><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> /> <label for="email">Mail (bleibt unter uns !)<?php if ($req) echo("das muss sein"); ?></label></p> <p><input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" /> <label for="url">Website</label></p> <?php endif; ?> <p><?php printf('<strong>XHTML:</strong> erlaubte Tags: <code>%s</code>', allowed_tags()); ?></p> <p><textarea name="comment" id="comment" cols="81" rows="10" tabindex="4"></textarea></p> <p><input name="submit" type="submit" id="submit" tabindex="5" value="Senden" /> <?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>
Wem das zu kompliziert ist, der kanns auch einfach übernehmen und mit dem css rumspielen. Hier der css Teil für die Kommentare.
/* Kommentare - das Styling der Kommentare */ .commentlist .quote { background:url(images/zitat.gif) no-repeat top right; } .commentlist li { padding: 5px 18px 22px 18px; margin-top:25px; background:#eeffee url(images/bg_commentlist.gif) bottom no-repeat; border:1px solid white; } .commentlist li.oddcomment{ background:#eeeeff url(images/bg_commentlist.gif) bottom no-repeat; } .commentlist { list-style-image:none; list-style-type:none; list-style-position:outside; } .commentmeta{ font-style:normal; font-size:85%; font-style:oblique; color:#777777; margin:-12px 10px 10px 0; float: right; } .commentmeta a{ font-size:inherit; color:#777777; } #commentwrap { clear:both; margin:20px; border:1px solid green; padding:20px; font-size:14px; } #commentwrap #respond * { font-size:12px; } #commentwrap #respond h6 { padding-top:15px; font-size:15px; }
Optisch ist unser Theme jetzt mal halbwegs fertig. In den weiteren Teilen gehen wir auf Verfeinerungen ein, die das Theme noch perfektionieren.
Das Theme zum jetzigen Stand gibt es HIER zum Download. Noch ist es sehr übersichtlich !


Artikel
[...] Teil 8 : Einfügen der Kommentarfunktion auf Einzelseiten. [...]
[...] Read the original here: Eigenes Theme Teil 8 Kommentare [...]