'Show Related posts loop based on tags
I want to show tag based post in related post. Here is the complete template code for my related post loop (loop.related.post. php ) What changes do I need to make in this loop? My theme is custom. I want to show 6 posts in related posts.
<?php
global $wpdb, $post, $wp_query;
$URLs_Link_MP3 = get_post_meta( $post->ID, 'URLs_Link_MP3', true );
$durations_MP3 = get_post_meta( $post->ID, 'durations_MP3', true );
if(!$durations_MP3) $durations_MP3 = '0';
global $wpdb, $post, $wp_query;
$durations_MP3 = get_post_meta( $post->ID, 'durations_MP3', true ); if(!$durations_MP3) $durations_MP3 = '0';?>
<div class="col-sm-6 item" data-id="<?php the_ID(); ?>" data-value="<?php echo $URLs_Link_MP3 ; ?>" >
<div class="row">
<div class="button dark player loader" duration="<?php echo $durations_MP3 ; ?>">
<svg class="icon icon-play">
<use xlink:href="#icon-play"/>
</svg>
</div>
<a class="details" href="<?php the_permalink() ?>" title="<?php the_title(); ?> PDF Download">
<h2 class="title"><?php the_title(); ?></h2>
<p><?php echo $durations_MP3 ; ?> <?php global $opt_themes; if($opt_themes['rtones_Sec']) { ?><?php echo $opt_themes['rtones_Sec']; ?><?php } ?> - <?= ex_themes_get_post_view_(); ?> <?php global $opt_themes; if($opt_themes['rtones_Author_Download']) { ?><?php echo $opt_themes['rtones_Author_Download']; ?><?php } ?></p>
</a>
</div>
<?php global $opt_themes; if($opt_themes['ex_themes_tags_all_active_']) { ?>
<div class="row">
<?php
$post_tags = get_the_tags();
if ( ! empty( $post_tags ) ) {
echo '<ul class="tags">';
foreach( $post_tags as $post_tag ) {
echo '<li><a href="' . get_tag_link( $post_tag ) . '">' . str_replace('ringtones', ' ', $post_tag->name) . '</a></li>';
}
echo '</ul>';
} else {
echo '<ul class="tags">';
echo '<li><a>no tags</a></li>';
echo '</ul>';
}
?>
</div>
<?php } ?>
<div class="row">
<div class="actions">
<div class="button light fav">
<?php if ( shortcode_exists( 'favorite_button' ) ): ?><?php echo do_shortcode( '[favorite_button]' ); ?><?php else: ?><?php endif;?>
</div>
<div class="button light share">
<svg class="icon">
<use xlink:href="#icon-share"/>
</svg>
</div>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<div class="button dark download">
<svg class="icon">
<use xlink:href="#icon-download2"/>
</svg>
</div>
</a>
</div>
</div>
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
