Moin,
ich bin Seit gestern Kunde von Themejunkie und habe das Newstube aufgesetzt. Nur hätte ich gern die related Posts aus dem Channelpro unter dem einzelnen Artikel. Die erforderlichen Code habe ich kopiert. Aber leider wird mir an statt des Bildes nur die Linkadresse des Bilder angezeigt. jemand eine Idee was ich falsch gemacht habe. Hier die Codes:
Functionscode:
PHP
function tj_related_posts() {
global $post, $wpdb;
$backup = $post; // backup the current object
$tags = wp_get_post_tags($post->ID);
$tagIDs = array();
if ($tags) {
$tagcount = count($tags);
for ($i = 0; $i < $tagcount; $i++) {
$tagIDs[$i] = $tags[$i]->term_id;
}
$showposts = get_theme_mod('related_postnum');
$showposts = !empty($showposts) ? $showposts : 4;
$args=array(
'tag__in' => $tagIDs,
'post__not_in' => array($post->ID),
'showposts'=>$showposts,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) { $related_post_found = true; ?>
<h3>Ähnliche News:</h3>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div class="related-post">
<?php
$thumb = get_thumbnail($post->ID, get_theme_mod('thumb_key'),get_theme_mod('thumb_key'));
$width = get_theme_mod('thumb_width');
$height = get_theme_mod('thumb_height');
$auto = get_theme_mod('thumb_auto');
if($thumb) {
if($auto == 'Yes')
$url = get_bloginfo('template_url').'/timthumb.php?src='.$thumb.'&h='.$height.'&w='.$width.'&a=t&zc=1';
else
$url = $thumb;
} else {
$url = get_bloginfo('template_url').'/images/default-thumb.gif';
}
echo '<a href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'"><img width="125" height="80" src="'.$url.'" alt="'.get_the_title().'" /></a>';
?> <a class="title" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
</div>
<?php endwhile; ?>
<?php }
}
//show recent posts if no related found
if(!$related_post_found){ ?>
<h3>Ähnliche News:</h3>
<?php
$posts = get_posts('numberposts=4');
foreach($posts as $post) { ?>
<div class="related-post">
<?php
$thumb = get_thumbnail($post->ID, get_theme_mod('thumb_key'),get_theme_mod('thumb_key'));
$width = get_theme_mod('thumb_width');
$height = get_theme_mod('thumb_height');
$auto = get_theme_mod('thumb_auto');
if($thumb) {
if($auto == 'Yes')
$url = get_bloginfo('template_url').'/timthumb.php?src='.$thumb.'&h='.$height.'&w='.$width.'&a=t&zc=1';
else
$url = $thumb;
} else {
$url = get_bloginfo('template_url').'/images/default-thumb.gif';
}
echo '<a href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'"><img width="125" height="80" src="'.$url.'" alt="'.get_the_title().'" /></a>';
?>
<a class="title" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
</div>
<?php } ?>
<?php
}
wp_reset_query();
}
?>
Alles anzeigen
Code unter dem contenet:
Css Code:
PHP
.entry-related { padding:0 0 10px 0; border-bottom:1px solid #ECEDE8; }
.entry-related h3 { margin-bottom:10px; }
.related-post { float:left; width:135px; margin:0 15px 0 0; }
.related-post img { background:#fff; padding:4px; border:1px solid #ECEDE8; }
.related-post h3 { margin:0 0 10px 0; }
.related-post .title { display:block; line-height:16px; margin:7px 0 0 0; }
Schon mal vielen Dank für eure Hilfe :)
Dr. Disco