Created
August 9, 2016 22:55
-
-
Save Quijaua/55599e4d4eaac0adf9470f73b58be4eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$tags = wp_get_post_tags($post->ID); | |
if ($tags) { | |
$first_tag = $tags[0]->term_id; | |
$args=array( | |
'tag__in' => array($first_tag), | |
'post__not_in' => array($post->ID), | |
'posts_per_page'=>4, | |
'caller_get_posts'=>1, | |
'orderby'=>'rand', | |
'suppress_filters' => 0, | |
); | |
$my_query = new WP_Query($args); | |
if( $my_query->have_posts() ) { | |
?> | |
<h4>Notícias relacionadas</h4> | |
<?php | |
while ($my_query->have_posts()) : $my_query->the_post(); | |
$url_thumb = wp_get_attachment_url( get_post_thumbnail_id( $post->ID) ); | |
?> | |
<div style="float:left;width:120px;padding:10px"> | |
<a href="<?php the_permalink(); ?>"><img src="<?php echo $url_thumb ?>" class="img-responsive"></a> | |
<h4><a href="<?php the_permalink(); ?>"><?php the_title( ); ?></a></h4> | |
</div> | |
<?php | |
endwhile; | |
} | |
wp_reset_query(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment