hangar-wp-theme/related-post.php

35 lines
706 B
PHP
Raw Normal View History

2021-02-18 14:09:56 +01:00
<?php $tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'showposts'=>3, // Number of related posts that will be shown.
'caller_get_posts'=>1
);
$my_query = new wp_query($args);
if( $my_query->have_posts() ) {
echo '<ul>';
while ($my_query->have_posts()) {
$my_query->the_post();
$tipus = 'catt';
include(TEMPLATEPATH . "/caixes.php");
}
}else {
echo '
<li>No hay contenidos relacionados';
}
echo '</li>
</ul>
';
}
wp_reset_query();
echo '</ul>';
?>