dsebao
9/17/2018 - 5:59 PM

Show related post in WP single page

<h5>Seguí leyendo</h5>
	<?php
	$related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 3, 'post__not_in' => array($post->ID) ) );
	if( $related ) foreach( $related as $post ) {
	setup_postdata($post);?>  

		<article>
			<div class="row">
				<div class="col-3">
				<?php if(my_image($post->ID, 'thumbnail')){?>
			    	<a href="<?php the_permalink();?>" class="image-link">
			    		<img src="<?php echo my_image($post->ID, 'thumbnail');?>" alt="<?php the_title();?>"></a>
					<?php }?>
				</div>
				<div class="col-9">
					<h4><a href="<?php the_permalink();?>" title="<?php the_title();?>"><?php the_title();?>”</a></h4>
					<time datetime="<?php echo get_the_date('Y-m-d\TH:i:sP'); ?>" itemprop="datePublished"><?php echo get_the_date(); ?> </time></span>
				</div>
			</div>
		</article>
	<?php }
	wp_reset_postdata(); ?>