Hallo Forum,
ich habe ein Theme für eine Seite zusammengebastelt, welches bisher auch ohne Probleme funktioniert.
Jetzt wollte ich eine Art Gästebuch einbauen, aber das scheint nicht so wirklich zu funktionieren.
Um das Ziel zu erreichen, habe ich eine neue Seite "Gästebuch" angelegt und ein entsprechendes Template angelegt (page-gasestebuch.php). Dieses Template integriert ein spezielles Kommentarformular (comments-gaestebuch.php), hier habe ich einige Beschriftungen geändert.
Der Kommentform wird mir auch angezeigt und ich kann einen Beitrag absenden, der mir im Backend auch als Kommentar angezeigt wird. Aber im Frontend wird dieses Kommentar auf der Seite nicht angezeigt.
Habe ich irgendwo einen Denkfehler?
page-gaestebuch.php:
<?php
/*
Template Name: Gaestebuch
*/
?>
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); update_post_caches($posts); ?>
<h2><?php the_title(); ?></h2>
<?php the_content('weiterlesen...'); ?>
<hr style="width:80%">
<?php if ( comments_open() ) include( TEMPLATEPATH . '/comments-gaestebuch.php' ); ?>
<?php endwhile; else : ?>
Sorry, es gibt keine entsprechenden Beiträge.
<?php endif; ?>
<?php get_footer(); ?>
Alles anzeigen
comments-gaestebuch.php
<?php // Do not delete these lines
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments-gaestebuch.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Diese Seite kann nicht direkt aufgerufen werden.');
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">Dieser Beitrag ist passwortgeschüzt.<br />Bitte das Passwort eingeben.</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('Bisher ist noch kein Eintrag vorhanden', 'Ein Eintrag', '% Einträge' );?></h3>
<ol id="comments">
<?php foreach ($comments as $comment) : ?>
<li id="comment-<?php comment_ID() ?>" <?php if ($comment % 2) echo "$oddcomment"; ?>>
<span class="gravatar"><?php echo get_avatar( $comment, 50 ); ?></span>
<?php comment_text() ?>
<p class="meta">Geschrieben von <?php comment_author_link() ?> am
<?php comment_date() ?> um <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?> Uhr</a>
<span><?php echo $i; ?></span>
<?php edit_comment_link(__("Diesen Eintrag bearbeiten"), ' | '); ?></p>
</li><br /><br />
<?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. -->
<p>Bisher ist noch kein Eintrag vorhanden.</p>
<?php else : // comments are closed ?>
<!-- If comments are closed. -->
<p class="nocomments"></p>
<?php endif; ?>
<?php endif; ?>
<?php if ('open' == $post->comment_status) : ?>
<h3 id="respond">Einen Eintrag im Gästebuch hinterlassen</h3>
<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
<p>Du musst <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">angemeldet</a> sein um einen Eintrag verfassen zu können.</p>
<?php else : ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform" style="text-align:justify">
<?php if ( $user_ID ) : ?>
<p style="text-align:justify;">Angemeldet als <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(); ?>" title="Log out of this account">Abmelden »</a></p>
<?php else : ?>
<p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
<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" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="email"><small>E-Mail (Wird nicht veröffentlicht) <?php if ($req) echo "(erforderlich)"; ?></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>Website</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="70%" rows="10" tabindex="4"></textarea></p>
<p align="left"><input name="submit" type="submit" id="submit" tabindex="5" value="Eintrag absenden" /></p>
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
<?php do_action('comment_form', $post->ID); ?>
</form
><?php endif; ?>
<?php endif; ?>
Alles anzeigen
Wäre echt klasse, wenn mir jemand auf die Sprünge helfen könnte.