wordpress - Display related post based on tag -


i'm working on music site uses lot of tags , categories per post. example, on artist's page related posts display artist's releases based on tags. have tried adding tag using wordpress' post_type $args = array( -

'post_type' => 'releases' 

but hasn't worked.

for example, here complete code -

<div class="relatedposts">             <h3>releases artist</h3>             <?php                 $orig_post = $post;                 global $post;                 $tags = wp_get_post_tags($post->id);                  if ($tags) {                 $tag_ids = array();                 foreach($tags $individual_tag) $tag_ids[] = $individual_tag->term_id;                 $args=array(                 'post_type' => 'releases',                 'tag__in' => $tag_ids,                 'post__not_in' => array($post->id),                 'posts_per_page'=>4, // number of related posts display.                 'caller_get_posts'=>1                 );                  $my_query = new wp_query( $args );                  while( $my_query->have_posts() ) {                 $my_query->the_post();                 ?>                  <div class="relatedthumb">                     <a rel="external" href="<? the_permalink()?>"><?php the_post_thumbnail(array(150,100)); ?><br />                     <?php the_title(); ?>                     </a>                 </div>                  <? }                 }                 $post = $orig_post;                 wp_reset_query();                 ?>             </div> 

i've followed lot of other stackoverflow posts , can't seem right result. going wrong ?!

<section class="row related">     <div class="row related-articles">         <h2 class="related-title">related content</h2>         <div class="relatedposts">             <?php         $orig_post = $post;         global $post;         $tags = wp_get_post_tags($post->id);          if ($tags) {             $tag_ids = array();         foreach($tags $individual_tag) $tag_ids[] = $individual_tag->term_id;             $args=array(                 'tag__in' => $tag_ids,                 'post__not_in' => array($post->id),                 'posts_per_page'=>3, // number of related posts display.                 'caller_get_posts'=>1             );          $my_query = new wp_query( $args );          while( $my_query->have_posts() ) {             $my_query->the_post();         ?>             <div class="large-4 medium-4 small-12 columns img-wrap"> <a rel="external" href="<? the_permalink()?>">                 <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->id, 'thumbnail') ); ?>                 <img src="<?php echo $url ?>" />                 <div class="story-title-sub">                     <h2>                         <?php the_title(); ?>                     </h2>                 </div>             </div>             <?php }         }         $post = $orig_post;         wp_reset_query();         ?>         </div>     </div> </section> 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -