I am using thesis and i am trying to display the related post by there tag name.
suppose i have post and that post have three tag or multiple
tag like tag:- 1) car, 2)automobile, 3) mechanical
so i want display the related post by the tag name of car,automobile,mechanical.
I am trying the bellow code with the thesis hook but its not displaying the related post by the tag name of that post its displaying another related post which have don't have any connection with these three tags of this post.
so any body can tell hot do this.
my function code:-
function tagpost(){
global $post;
$tag = get_the_tags();
foreach ($tag as $tags){
?>
<div class="relatedpostAdd post<?php echo $tags->term_id; ?>">
<h3 style="margin:5px 0 "><?php echo $tags->name; ?></h3>
<ul>
<?php
$posts = get_posts('numberposts=6&term_id='. $tags->term_id);
foreach($posts as $post) {
?>
<li>
<div class="images_releted">
<a class="post_thumbnail" href="<? the_permalink()?>" rel="bookmark"
title="<?php the_title(); ?>">
<?php echo the_post_thumbnail('thumbnail') ?>
</a>
</div>
<a class="post_thumbnail_link" href="<? the_permalink();?>" rel="bookmark"
title="<?php the_title(); ?>">
<?php the_title(); ?></a>
</li>
<?php } ?>
</ul>
</div>
<?php }
}
add_action('thesis_hook_after_post_box_related_posts','tagpost');
get_posts
arguments are wrong. Usetag_id
, notterm_id
– Pieter Goosen Nov 19 '14 at 7:49