Hallo,
Ich habe mir ein Template umgebaut und in diesem ist in der Sidebar eine Multibox mit Recent Comments Popular Posts etc (http://partyfotos.netai.net). Allerdings habe ich das Problem, dass die Kommentare nicht in der richtigen spate angezeigt werden, sonder nur einmal wenn ich die Hauptseite aufrufe, dann stehen diese unter Popular...
Hier die Quelltexte aus der functions.php und sidebar.php:
<?php
include("settings.php");
# WIDGET: Sidebar
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Sidebar',
'before_title' => '<h2>',
'after_title' => '</h2>',
'before_widget' => '',
'after_widget' => '',
));
# WIDGET: Sidebar
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Footer Left',
'before_title' => '<h2>',
'after_title' => '</h2>',
'before_widget' => '<div class="box">',
'after_widget' => '</div>',
));
# WIDGET: Sidebar
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Footer Center',
'before_title' => '<h2>',
'after_title' => '</h2>',
'before_widget' => '<div class="box">',
'after_widget' => '</div>',
));
# WIDGET: Sidebar
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Footer Right',
'before_title' => '<h2>',
'after_title' => '</h2>',
'before_widget' => '<div class="box">',
'after_widget' => '</div>',
));
# Displays a list of pages
function dp_list_pages() {
global $wpdb;
$querystr = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'page' ORDER BY $wpdb->posts.post_title ASC";
$pageposts = $wpdb->get_results($querystr, OBJECT);
if ($pageposts) {
foreach ($pageposts as $post) {
?><li><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a></li><?php
}
}
}
# Displays a list of categories
function dp_list_categories($num=0, $exclude='') {
if (strlen($exclude)>0) $exclude = '&exclude=' . $exclude;
$categories = get_categories('hide_empty=1'.$exclude);
$first = true; $count = 0;
foreach ($categories as $category) {
if ($num>0) { $count++; if ($count>$num) break; } // limit
if ($category->parent<1) {
if ($first) { $first = false; $f = ' class="f"'; } else { $f = ''; }
?><li<?php echo $f; ?>>
<a href="<?php echo get_category_link($category->cat_ID); ?>"><?php echo $category->name ?><?php echo $raquo; ?></a></li>
<?php
}
}
}
# Displays a list of popular posts
function dp_popular_posts($num, $pre='<li>', $suf='</li>', $excerpt=true) {
global $wpdb;
$querystr = "SELECT $wpdb->posts.post_title, $wpdb->posts.ID, $wpdb->posts.post_content FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'post' ORDER BY $wpdb->posts.comment_count DESC LIMIT $num";
$myposts = $wpdb->get_results($querystr, OBJECT);
foreach($myposts as $post) {
echo $pre;
?><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title ?></a><?php
if ($excerpt) {
?><p><?php echo dp_clean($post->post_content, 80); ?>...</p><?php
}
echo $suf;
}
}
# Displays a list of recent categories
function dp_recent_comments($num) {
global $wpdb, $post;
$querystr = "SELECT $wpdb->comments.comment_ID, $wpdb->comments.comment_post_ID, $wpdb->comments.comment_content, $wpdb->comments.comment_author FROM $wpdb->comments WHERE $wpdb->comments.comment_approved=1 ORDER BY $wpdb->comments.comment_date DESC LIMIT $num";
$recentcomments = $wpdb->get_results($querystr, OBJECT);
$first = true;
foreach ($recentcomments as $rc) {
if ($first) {
$first = false;
$pre = '<li class="first">';
} else {
$pre = '<li>';
}
$post = get_post($rc->comment_post_ID);
echo $pre;
?><strong><a href="<?php the_permalink() ?>#comment-<?php echo $rc->comment_ID ?>"><?php echo $rc->comment_author; ?> says:</a></strong> <?php echo dp_clean($rc->comment_content, 80); ?></li><?php
}
}
# Displays post image attachment (sizes: thumbnail, medium, full)
function dp_attachment_image($postid=0, $size='thumbnail', $attributes='') {
if ($postid<1) $postid = get_the_ID();
if ($images = get_children(array(
'post_parent' => $postid,
'post_type' => 'attachment',
'numberposts' => 1,
'post_mime_type' => 'image',)))
foreach($images as $image) {
$attachment=wp_get_attachment_image_src($image->ID, $size);
?><img src="<?php echo $attachment[0]; ?>" <?php echo $attributes; ?> /><?php
}
}
# Removes tags and trailing dots from excerpt
function dp_clean($excerpt, $substr=0) {
$string = strip_tags(str_replace('[...]', '...', $excerpt));
if ($substr>0) {
$string = substr($string, 0, $substr);
}
return $string;
}
# Displays the comment authors gravatar if available
function dp_gravatar($size=50, $attributes='', $author_email='') {
global $comment, $settings;
if (dp_settings('gravatar')=='enabled') {
if (empty($author_email)) {
ob_start();
comment_author_email();
$author_email = ob_get_clean();
}
$gravatar_url = 'http://www.gravatar.com/avatar/' . md5(strtolower($author_email)) . '?s=' . $size . '&d=' . dp_settings('gravatar_fallback');
?><img src="<?php echo $gravatar_url; ?>" <?php echo $attributes ?>/><?php
}
}
# Retrieves the setting's value depending on 'key'.
function dp_settings($key) {
global $settings;
return $settings[$key];
}
?>
Alles anzeigen
<!-- begin multi-list -->
<div class="box">
<ul class="navigation">
<li class="active"><a class="popular" href="#">Popular</a></li>
<li><a class="recent" href="#">Recent</a></li>
<li><a class="comments" href="#">Comments</a></li>
<li><a class="tags" href="#">Tags</a></li>
</ul>
<div class="multilist">
<!-- begin popular -->
<ul id="popular">
<?php dp_popular_posts(3); ?>
</ul>
<!-- end popular -->
<!-- begin recent -->
<ul id="recent">
<?php
query_posts('orderby=date&order=DESC&showposts=3');
while (have_posts()) : the_post();
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br/><?php echo dp_clean($post->post_content, 80); ?></li>
<?php
endwhile;
?>
</ul>
<!-- end recent -->
<!-- begin comments -->
<ul class="comments">
<?php dp_recent_comments(5); ?>
</ul>
<!-- end comments -->
<!-- begin tags -->
<div id="tags">
<?php wp_tag_cloud(); ?>
</div>
<!-- end tags -->
</div>
</div>
<!-- end multi-list -->
Alles anzeigen
Ich hoffe jemand weiß woran es liegt..
Danke