Hallo,
ich würde meinen Artikeln gern "Related Posts" über eine single.php zufügen. Wenn ich den entsprechenden Code dafür einbaue sitzen die Posts ganz unten am Ende des Artikels, noch unter dem Kommentarfeld. Ich hätte sie gern dadrüber, vor dem Kommentarfeld.
Ist das möglich?
Hier mal die Codes,
Related Posts Code:
PHP
- <?php$tags = wp_get_post_tags($post->ID); if ($tags) { $the_tags = array(); foreach($tags as $each_tag) $the_tags[] = $each_tag->term_id; $args=array( 'tag__in' => $the_tags, 'post__not_in' => array($post->ID), 'showposts' => 5, // Anzahl der aufzulistenden Artikel 'caller_get_posts' => 1 // Verhindert, dass Sticky Posts gelistet werden ); $new_query = new WP_Query($args); if( $new_query->have_posts() ) { echo '<h3>Ähnliche Artikel</h3><ul>'; // Überschrift der Liste while ($new_query->have_posts()) { $new_query->the_post(); ?> <li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li> <?php } echo '</ul>'; } }?>
single.php Code:
PHP
- <?php
- /**
- * The Template for displaying all single posts.
- *
- * @package WordPress
- * @subpackage Twenty_Ten
- * @since Twenty Ten 1.0
- */
- get_header(); ?>
- <div id="container">
- <div id="content" role="main">
- <?php
- /* Run the loop to output the post.
- * If you want to overload this in a child theme then include a file
- * called loop-single.php and that will be used instead.
- */
- get_template_part( 'loop', 'single' );
- ?>
- </div><!-- #content -->
- </div><!-- #container -->
- <?php get_sidebar(); ?>
- <?php get_footer(); ?>