Hey,
Sry das ich jeden zweiten Tag ne Frage hab :)
Aber irgendwie krieg ich wieder einmal nichts hin!
Und zwar geht es um die Funktion "Ähnliche Beiträge" unter folgenden Link: http://www.plerzelwupp.de/wordpress-hacks/ hab ich dazu den Code gefunden. Und hab ihn unter den "Content" eingefügt nur kann ich dann die Artikel nicht aufrufen und es steht Error…
Hier mein Code der single.php Datei:
<?php get_header() ?>
<div id="container">
<div id="content">
<?php the_post(); ?>
<div id="post-<?php the_ID(); ?>">
<h2 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Permalink to %s', 'sandbox'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></a></h2>
<div class="entry-meta">
<span class="author vcard"><?php printf(__('Posted by %s on ', 'sandbox'), '<a class="url fn n" href="'.get_author_link(false, $authordata->ID, $authordata->user_nicename).'" title="' . sprintf(__('View all posts by %s', 'sandbox'), $authordata->display_name) . '">'.get_the_author().'</a>') ?></span><abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO'); ?>"><?php unset($previousday); printf(__('%1$s – %2$s', 'sandbox'), the_date('', '', '', false), get_the_time()) ?></abbr>
</div>
<div class="entry-categ">
<span class="cat-links"><?php printf(__('Filed under %s', 'sandbox'), get_the_category_list(', ')) ?></span>
</div>
<div class="entry-content">
<?php the_content(''.__('Read More <span class="meta-nav">»</span>', 'sandbox').''); ?>
<?php wp_link_pages("\t\t\t\t\t<div class='page-link'>".__('Pages: ', 'sandbox'), "</div>\n", 'number'); ?>
</div>
<div class="entry-footer">
<?php printf(__('<a href="%1$s" title="Permalink to %2$s" rel="bookmark">Permalink</a><span>|</span><a href="%3$s" title="Comments RSS to %2$s" rel="alternate" type="application/rss+xml">Comments RSS Feed</a> <span>-</span>', 'sandbox'), get_permalink(), wp_specialchars(get_the_title(), 'double'), comments_rss() ) ?>
<?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) : // Comments and trackbacks open ?>
<?php printf(__('<a class="comment-link" href="#respond" title="Post a comment">Post a comment</a><span>|</span><a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'sandbox'), get_trackback_url()) ?>
<?php elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) : // Only trackbacks open ?>
<?php printf(__('Comments are closed<span>|</span><a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'sandbox'), get_trackback_url()) ?>
<?php elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) : // Only comments open ?>
<?php printf(__('Trackbacks are closed<span>|</span><a class="comment-link" href="#respond" title="Post a comment">post a comment</a>.', 'sandbox')) ?>
<?php elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) : // Comments and trackbacks closed ?>
<?php _e('Both comments and trackbacks are currently closed.') ?>
<?php endif; ?>
</div>
</div><!-- .post -->
<?php comments_template(); ?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar() ?>
<?php get_footer() ?>
Alles anzeigen
Und hier der Code der Funktion:
<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
echo 'Related Posts';
$first_tag = $tags[0]->term_id;
$args=array(
'tag__in' => array($first_tag),
'post__not_in' => array($post->ID),
'showposts'=>5,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark"
title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?></a></p>
<?php
endwhile;
}
}
?>
Alles anzeigen
Ich würde mich über Antwort freuen!
Gruß
Vincent