Guten Abend,
ich habe Wordpress in meine bereits bestehende Seite integrieren wollen bzw. es sogar schon getan. Dazu hatte ich den (hier im Forum gefundenen) folgenden Code verwendet:
<?php require('./wp-blog-header.php'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('j. F Y') ?> <!-- von <?php the_author() ?> --></small>
<div class="entry">
<?php the_content('Den ganzen Beitrag lesen »'); ?>
</div>
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Kategorie <?php the_category(', ') ?> <strong>|</strong> </p>
</div>
<?php endwhile; ?>
<?php else : ?>
<h2 class="center">Nicht gefunden</h2>
<p class="center">Sorry, aber du suchst gerade nach etwas, was hier nicht ist.</p>
<?php endif; ?>
Alles anzeigen
Das hat auch wunderbar funktioniert, aber da ich auch die Kommentarfunktion nutzen möchte, ist das alles andere als ideal gewesen, weil man beim Klick auf den entsprechenden Post auf den "Original-Blog" gekommen ist, was zu meinem Design und meinen Vorstellungen so überhaupt nicht passt.
Dann hatte ich die mehr oder weniger gute Idee, die Kommentare plus Formular so drunter zu basteln, dass sie beim Klick auf einen "Kommentare anzeigen" Link ausgeklappt werden.
Das habe ich seeeeeeehr stümperhaft so gelöst:
(kompletter Code)
<?php require('wordpress/wp-blog-header.php'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<b><font size="3"><?php the_title(); ?></b></font><br><br>
<small><?php the_time('j. F Y') ?> <!-- von <?php the_author() ?> --></small>
<div class="entry">
<?php the_content('Den ganzen Beitrag lesen »'); ?>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<h2 class="center">Nicht gefunden</h2>
<p class="center">Sorry, aber du suchst gerade nach etwas, was hier nicht ist.</p>
<?php endif; ?>
<table>
<tr>
<td><a href="#" onclick="versteckt()">Kommentare »</a></td>
</tr>
<tr>
<td style="display : none" id="ghost">
<?php
/* Don't remove these lines. */
add_filter('comment_text', 'popuplinks');
if ( have_posts() ) :
while( have_posts()) : the_post();
?>
<?php if ( pings_open() ) { ?>
<?php } ?>
<?php
// this line is WordPress' motor, do not delete it.
$commenter = wp_get_current_commenter();
extract($commenter);
$comments = get_approved_comments($id);
$post = get_post($id);
if ( post_password_required($post) ) { // and it doesn't match the cookie
echo(get_the_password_form());
} else { ?>
<?php if ($comments) { ?>
<ol id="commentlist">
<?php foreach ($comments as $comment) { ?>
<li id="comment-<?php comment_ID() ?>">
<?php comment_text() ?>
<p><cite><?php comment_type(__('Comment', 'kubrick'), __('Trackback', 'kubrick'), __('Pingback', 'kubrick')); ?> <?php printf(__('by %1$s — %2$s @ <a href="#comment-%3$s">%4$s</a>', 'kubrick'), get_comment_author_link(), get_comment_date(), get_comment_ID(), get_comment_time()); ?></cite></p>
</li>
<?php } // end for each comment ?>
</ol>
<?php } else { // this is displayed if there are no comments so far ?>
<p><?php _e('No comments yet.', 'kubrick'); ?></p>
<?php } ?>
<?php if ( comments_open() ) { ?>
<a href="#" onclick="versteckt1()">Kommentar schreiben »</a></td>
</tr>
<tr>
<td id="ghost1" style="display : none">
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ( $user_ID ) : ?>
<p><?php printf(__('Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out »</a>', 'kubrick'), get_option('siteurl') . '/wp-admin/profile.php', $user_identity, wp_logout_url()); ?></p>
<?php else : ?>
<p>
<input type="text" name="author" id="author" class="textarea" value="<?php echo esc_attr($comment_author); ?>" size="28" tabindex="1" />
<label for="author"><?php _e('Name', 'kubrick'); ?></label>
</p>
<p>
<input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="28" tabindex="2" />
<label for="email"><?php _e('E-mail', 'kubrick'); ?></label>
</p>
<p>
<input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="28" tabindex="3" />
<label for="url"><?php _e('Homepage', 'kubrick'); ?></label>
</p>
<?php endif; ?>
<p>
<label for="comment"><?php _e('Your Comment', 'kubrick'); ?></label>
<br />
<textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
</p>
<p>
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
<input type="hidden" name="redirect_to" value="<?php echo esc_attr($_SERVER["REQUEST_URI"]); ?>" />
<input name="submit" type="submit" tabindex="5" value="<?php _e('Say It!' , 'kubrick'); ?>" />
</p>
<?php do_action('comment_form', $post->ID); ?>
</form>
<?php } else { // comments are closed ?>
<p><?php _e('Sorry, the comment form is closed at this time.', 'kubrick'); ?></p>
<?php }
} // end password check
?>
<?php // if you delete this the sky will fall on your head
endwhile; // have_posts()
else: // have_posts()
?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<!-- // this is just the end of the motor - don't touch that line either :) -->
<?php //} ?>
<p class="credit"><?php timer_stop(1); ?>
<?php // Seen at http://www.mijnkopthee.nl/log2/archive/2003/05/28/esc(18) ?>
<script type="text/javascript">
<!--
document.onkeypress = function esc(e) {
if(typeof(e) == "undefined") { e=event; }
if (e.keyCode == 27) { self.close(); }
}
// -->
</script><?php
/**
* @package WordPress
* @subpackage Default_Theme
*/
// 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"><?php _e('This post is password protected. Enter the password to view comments.', 'kubrick'); ?></p>
<?php
return;
}
?>
</div>
Alles anzeigen
Das Ganze sieht dann so aus (es ist noch dieses Javascript für die Ausklappfunktion eingebaut) und war auch für's erste zumindest funktionell (auch wenn es wie gesagt absolut zusammengeschustert ist). Aber idiotischerweise klappt das nur einmal. Sobald ein zweiter Eintrag dazu kommt, ist dieser ohne diese gebastelte Kommentarfunktion, womit ich eigentlich auch hätte rechnen können, wenn ich mal so drüber nachdenke.
Langes Geschwafel kurzer Sinn: Gibt es eine Möglichkeit das Ganze auf alle Einträge zu übertragen? Ich möchte möglichst darum rumkommen, das gesamte Template meinem Homepage Design anzupassen ;-)
Schonmal vielen Dank, falls irgendjemand überhaupt verstehen sollte, was ich möchte.
Gruß
Gurke
PS: Ja ich weiß, dass meine Art Codes zusammenzubasteln mehr als unzureichend ist und gelinde gesagt sind sie auch 'ne mittlere Katastrophe :oops: