Beiträge von jottlieb
-
-
Stimmt. Auf den Trichter bin ich noch nicht gekommen :mrgreen:
Das dürfte wohl klappen.Ansonsten überschätzt ihr meine Arbeit ein bisschen. Ist ja wirklich nur die Anwendung von Conditional Tags und dass man dann eben das zweite Kommentarformular einfach entmüllt und leicht abändert - so wie man es braucht.
PS/OffTopic: Wenn ihr wüsstet, was man alles tolles mit den Benutzderdefinierten Feldern anstellen kann
Die werden auch sehr unterschätzt. -
Hallo Jottlieb,
tolle Arbeit. Mich würde interessieren ob es die Möglichkeit gibt eine separate Comments.php anzulegen. Damit es etwas übersichtlicher wird.
Genau das habe ich probiert, aber ich bin gescheitert.
Man muss leider die Funktions comment_template() benutzen.
Tut man das nicht, sondern included einfach nur die comments.php, so funktioniert das nicht - es werden keine Kommentare angezeigt. -
Gib did_action in die Forensuche ein.
-
-
In der FAQ gibt es einen Eintrag der fast genauso wie deine Frage formuliert ist:
WordPress Deutschland FAQ » Wie kann ich bestimmte Seiten von der Auflistung ausschließen? -
Template Tags/wp list categories − WordDoku
Du kannst nach Name (Standard), ID oder Anzahl sortieren lassen.
Evtl. gibt es auch Plugins die mehr Möglichkeiten bieten.Aber ich möchte dich darauf hinweisen, dass WordPress ja schon selber eine Archivfunktion mitbringt, die auch nach Monaten sortieren kann. So dass das evtl. überflüssig ist, was du vorhast.
Template Tags/wp get archives − WordDoku -
Und so sieht die angepasste Version aus:
PHP
Alles anzeigen<?php if (! is_page('linkvorschlage')) { ?> <?php // Do not delete these lines if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Bitte diese Seite nicht direkt aufrufen. Danke!'); if (!empty($post->post_password)) { // if there's a password if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie ?> <p class="nocomments">Auch die Kommentare sind durch das Passwort geschützt.</p> <?php return; } } /* This variable is for alternating comment background */ $oddcomment = 'class="alt" '; ?> <!-- You can start editing here. --> <?php if ($comments) : ?> <h3 id="comments"><?php comments_number('Keine Reaktion', 'Eine Reaktion', '% Reaktionen' );?> zu “<?php the_title(); ?>”</h3> <ol class="commentlist"> <?php foreach ($comments as $comment) : ?> <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"> <cite><?php comment_author_link() ?></cite> <?php if ($comment->comment_approved == '0') : ?> <br /><br /><strong>Achtung: Der Kommentar muß erst noch freigegeben werden.</strong> <?php endif; ?> <br /> <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title="#comment-<?php comment_ID() ?>">Am <?php comment_date('j. F Y') ?> um <?php comment_time('H:i') ?> Uhr</a> <?php edit_comment_link('Bearbeiten','<strong>|</strong>',''); ?></small> <?php comment_text() ?> </li> <?php /* Changes every other comment to a different class */ $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : ''; ?> <?php endforeach; /* end for each comment */ ?> </ol> <?php else : // this is displayed if there are no comments so far ?> <?php if ('open' == $post->comment_status) : ?> <!-- If comments are open, but there are no comments. --> <?php else : // comments are closed ?> <!-- If comments are closed. --> <p class="nocomments">Kommentarfunktion ist deaktiviert</p> <?php endif; ?> <?php endif; ?> <?php if ('open' == $post->comment_status) : ?> <h3 id="respond">Einen Kommentar schreiben</h3> <?php if ( get_option('comment_registration') && !$user_ID ) : ?> <p>du mußt <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">angemeldet</a> sein, um kommentieren zu können.</p> <?php else : ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> <?php if ( $user_ID ) : ?> <p>Angemeldet als: <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="von diesem Account abmelden">Abmelden »</a></p> <?php else : ?> <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" /> <label for="author"><small>Name <?php if ($req) echo "(erforderlich)"; ?></small></label></p> <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" /> <label for="email"><small>eMail <?php if ($req) echo "(erforderlich)"; ?> (wird nicht veröffentlicht)</small></label></p> <p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" /> <label for="url"><small>Webseite</small></label></p> <?php endif; ?> <!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>--> <p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p> <p><input name="submit" type="submit" id="submit" tabindex="5" value="senden" /> <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /> </p> <?php do_action('comment_form', $post->ID); ?> </form> <?php endif; // If registration required and not logged in ?> <?php endif; // if you delete this the sky will fall on your head ?> <?php } else { // Hier kommt der Code fuer die Linkvorschlaege ?> <?php // Do not delete these lines if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Bitte diese Seite nicht direkt aufrufen. Danke!'); /* This variable is for alternating comment background */ $oddcomment = 'class="alt" '; ?> <!-- You can start editing here. --> <?php if ($comments) : ?> <?php foreach ($comments as $comment) : ?> <div id="comment-<?php comment_ID() ?>"> Vorschlag von <?php comment_author_link() ?>: <?php if ($comment->comment_approved == '0') : ?> <br /><br /><strong>Achtung: Der Linkvorschlag muß erst noch freigegeben werden.</strong> <?php endif; ?> <br /> <?php comment_text() ?> </div> <?php /* Changes every other comment to a different class */ $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : ''; ?> <?php endforeach; /* end for each comment */ ?> <?php else : // this is displayed if there are no comments so far ?> Keine Vorschläge bisher. <?php endif; ?> <?php if ('open' == $post->comment_status) : ?> <h3 id="respond">Einen Link vorschlagen</h3> <?php if ( get_option('comment_registration') && !$user_ID ) : ?> <p>du mußt <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">angemeldet</a> sein, um einen Vorschlag absenden zu können.</p> <?php else : ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> <?php if ( $user_ID ) : ?> <p>Angemeldet als: <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="von diesem Account abmelden">Abmelden »</a></p> <?php else : ?> <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" /> <label for="author"><small>Name <?php if ($req) echo "(erforderlich)"; ?></small></label></p> <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" /> <label for="email"><small>eMail <?php if ($req) echo "(erforderlich)"; ?> (wird nicht veröffentlicht)</small></label></p> <?php endif; ?> <!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>--> <p><textarea name="comment" id="comment" cols="100%" rows="4" tabindex="4"></textarea></p> <p><input name="submit" type="submit" id="submit" tabindex="5" value="senden" /> <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /> </p> <?php do_action('comment_form', $post->ID); ?> </form> <?php endif; // If registration required and not logged in ?> <?php endif; // if you delete this the sky will fall on your head ?> <?php } ?>
Im zweiten Teil der Datei wird dann festgelegt, wie die Kommentare für die Linkvorschläge aussehen. Der erste Teil des Codes betrifft die normalen Kommentare.Abschließend habe ich eine neue Seite mit dem Titel "Linkvorschläge" erstellt und als Seiten-Template "Linkvorschlaege" ausgewählt.
Et voila... -
Anschließend musste nur noch die comments.php des Themes modifiziert werden. Ich habe eine Abfrage eingebaut, die nur bei Linkvorschläge-Seite einen leicht anderen Code nimmt.
Das Original sah so aus:PHP
Alles anzeigen<?php // Do not delete these lines if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Bitte diese Seite nicht direkt aufrufen. Danke!'); if (!empty($post->post_password)) { // if there's a password if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie ?> <p class="nocomments">Auch die Kommentare sind durch das Passwort geschützt.</p> <?php return; } } /* This variable is for alternating comment background */ $oddcomment = 'class="alt" '; ?> <!-- You can start editing here. --> <?php if ($comments) : ?> <h3 id="comments"><?php comments_number('Keine Reaktion', 'Eine Reaktion', '% Reaktionen' );?> zu “<?php the_title(); ?>”</h3> <ol class="commentlist"> <?php foreach ($comments as $comment) : ?> <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"> <cite><?php comment_author_link() ?></cite> <?php if ($comment->comment_approved == '0') : ?> <br /><br /><strong>Achtung: Der Kommentar muß erst noch freigegeben werden.</strong> <?php endif; ?> <br /> <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title="#comment-<?php comment_ID() ?>">Am <?php comment_date('j. F Y') ?> um <?php comment_time('H:i') ?> Uhr</a> <?php edit_comment_link('Bearbeiten','<strong>|</strong>',''); ?></small> <?php comment_text() ?> </li> <?php /* Changes every other comment to a different class */ $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : ''; ?> <?php endforeach; /* end for each comment */ ?> </ol> <?php else : // this is displayed if there are no comments so far ?> <?php if ('open' == $post->comment_status) : ?> <!-- If comments are open, but there are no comments. --> <?php else : // comments are closed ?> <!-- If comments are closed. --> <p class="nocomments">Kommentarfunktion ist deaktiviert</p> <?php endif; ?> <?php endif; ?> <?php if ('open' == $post->comment_status) : ?> <h3 id="respond">Einen Kommentar schreiben</h3> <?php if ( get_option('comment_registration') && !$user_ID ) : ?> <p>du mußt <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">angemeldet</a> sein, um kommentieren zu können.</p> <?php else : ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> <?php if ( $user_ID ) : ?> <p>Angemeldet als: <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="von diesem Account abmelden">Abmelden »</a></p> <?php else : ?> <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" /> <label for="author"><small>Name <?php if ($req) echo "(erforderlich)"; ?></small></label></p> <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" /> <label for="email"><small>eMail <?php if ($req) echo "(erforderlich)"; ?> (wird nicht veröffentlicht)</small></label></p> <p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" /> <label for="url"><small>Webseite</small></label></p> <?php endif; ?> <!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>--> <p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p> <p><input name="submit" type="submit" id="submit" tabindex="5" value="senden" /> <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /> </p> <?php do_action('comment_form', $post->ID); ?> </form> <?php endif; // If registration required and not logged in ?> <?php endif; // if you delete this the sky will fall on your head ?>Teil 3 im nächsten Post.
-
Ok.
Hier die Seite zum Links vorschlagen:
http://3zg.de/up/images/319607wplink1.gifWie du siehst, sieht das nicht mehr nach normalen Kommentaren aus, obwohl die Kommtarfunktion woanders (http://3zg.de/up/images/928792wplink2.gif) noch im alten Aussehen funktioniert.
Die Codebeispiele beziehen sich hier auf Kubrick, bei anderen Themes gibt es Unterschiede.
Erstmal habe in ein Duplikat der page.php des Themes angelegt und ihm einen netten Namen gegeben. Diese Datei wurde mit comments_template ergänzt, weil das Kubrick bei den Seiten nicht drin ist. Außerdem wurde der Template-Header ergänzt (ganz am Anfang) der Datei.
Die Datei (heißt bei mir linkvorschlaege.php) sieht also so aus:PHP
Alles anzeigen<?php /* Template Name: Linkvorschlaege */ ?> <?php get_header(); ?> <div id="content" class="narrowcolumn"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><?php the_title(); ?></h2> <div class="entry"> <?php the_content('<p class="serif"><strong>Den ganzen Beitrag lesen...</strong></p>'); ?> <?php wp_link_pages(array('before' => '<p><strong>Seiten:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> </div> </div> <?php comments_template(); ?> <?php endwhile; endif; ?> <?php edit_post_link('Beitrag bearbeiten.', '<p>', '</p>'); ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>Die normale page.php sieht übrigens so aus:
PHP
Alles anzeigen<?php get_header(); ?> <div id="content" class="narrowcolumn"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><?php the_title(); ?></h2> <div class="entry"> <?php the_content('<p class="serif"><strong>Den ganzen Beitrag lesen...</strong></p>'); ?> <?php wp_link_pages(array('before' => '<p><strong>Seiten:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> </div> </div> <?php endwhile; endif; ?> <?php edit_post_link('Beitrag bearbeiten.', '<p>', '</p>'); ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>Teil 2 kommt im nächsten Post.
-
Sollen die Links auch außerhalb der Seite, also z.B. immer in der Sidbar angezeigt werden?
(Das würde die Sache etwas komplizierter machen)
Oder nur auf dieser Extraseite? -
Wie könnte ich das denn ändern, so dass die Kommentare gleich auf der Hauptseite (also unter Linkvorschläge) erscheinen. Sonst muss man die Kommentare extra öffnen, oder ?
Auch das sollte möglich sein.
Man lässt in in einem zweiten Loop nur jenen bestimmten Beitrag bzw. Seite anzeigen und dazu die Kommentare (vielleicht in begrenzter Anzahl).Ich versuche mal Beispielhaft was zu basteln um meine These zu belegen

-
Warum sind die Kommentare zu unübersichtlich? Denke daran, dass man ja auch die Anzeige der Kommentare ändern kann. Im Extremfall sogar bis dahin dass es garnicht mehr nach Kommentaren im herkörmlichen Sinne aussieht.
-
-
-
Schaue mal ob da nicht ein Leerzeichen oder so in der functions.php am Anfang ist. Sowas darf nicht sein.
-
Ah ja da fehlt noch was. Füge deinem Theme eine functions.php hinzu in der nur das drinsteht:
-
Ersetzte Spaßeshalber mal
mit
Aber eigentlich sollten beide das gleiche machen.Achja: Du musst das Widget im Adminmenü dann natürlich auch aktivieren in dem du es in deine Sidebar ziehst.
-
Ich habe dieses Problem mit dem Theme Classy 1.0 gehabt. Habe mich nun so oder so für das Theme relaxation_3column entschieden auch dort ist dieses Problem vorhanden.
Unter dem Default theme habe ich das Problem nicht,wo drin könnte der Unterschied liegen ?
Uff, seltsam.
Classy (jedenfalls das hier aus dem Themebrowser) macht ja keine Extrawurst in Sachen Code. Hmm. Hast du dem Beitrag auch eine Kategorie zugewiesen? -
Das erklärt einiges, nur wo finde ich dann das PW für meinen eigenen Blog? In der "wp-config.php" hab ich bereits geschaut. Alomo
Das wurde dir bei der Installation mitgeteilt und sollte auch per Mail versendet worden sein.
Wenn nicht, nutze die Funktion "Passwort vergessen".