man4toman گفت:
این با تگ هست. خودمم از همین متد استفاده میکنم:
http://www.wprecipes.com/how-to-show-related-posts-without-a-plugin
بسیار تشکر. برای استایلش که میخوام کادر دار باشه یه راهنمایی میکنید؟
ضمناْ کد رو داخل حلقه گذاشتم کار نکرد! اینم single.php بعد اضافه کردن کد:
<?php get_header(); ?>
<?php
global $options;
foreach ($options as $value) {
if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); } }
?>
<div id="container2">
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/content-top-home-2.gif" alt="logo" style="float: left;" />
<div id="left-div">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<!--Begin Post-->
<div class="post-wrapper">
<h1 class="titles2"><a href="<?php the_permalink() ?>" rel="bookmark" title="لینک ثابت <?php the_title(); ?>"><?php the_title(); ?></a></h1>
<div style="clear: both;"></div>
<div class="post-info">
توسط <?php the_author() ?> در دسته <?php the_category(', ') ?> در <?php the_time('m jS, Y') ?> | <a href="#respond" title="<?php _e("دیدگاه شما در"); ?>"><?php comments_number('بدون دیدگاه','1 دیدگاه','% دیدگاه'); ?></a>
| <?php the_views() ?> | <?php if(function_exists(getILikeThis)) getILikeThis('get'); ?>
</div>
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/comment-bottom.gif" alt="logo" style="float: left; margin-bottom: 20px;" />
<div style="clear: both;"></div>
<?php the_content ('ادامه...'); ?>
<?php
//for use in the loop, list 5 post titles related to first tag on current post
$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;
}
}
?>
<div class="comment-bg">
<?php comments_template(); ?>
<div style="clear: both;"></div>
</div>
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/comment-bottom.gif" alt="logo" style="float: left; margin-bottom: 20px;" />
<?php endwhile; ?>
</div>
<?php else : ?>
<h2 align="center">یافت نشد!</h2>
<p align="center">متاسفانه مطلبی مطابق با معیار شما یافت نشد. دوباره تلاش کنید</p>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/content-bottom-2.gif" alt="logo" style="float: left;" />
</div>
<?php get_footer(); ?>
</body>
</html>