getfluid
3/9/2018 - 7:22 PM

Related Posts, randomly pulled in the same category, excluding the current post.

Related Posts, randomly pulled in the same category, excluding the current post.

{{
  $postid = get_the_ID();
	$cat = get_the_category();
  $args = [
    'post_type' => 'post',
    'post__not_in' => [$postid],
		'posts_per_page' => 2,
		'orderby' => 'rand',
		'tax_query' => [
			[
				'taxonomy' => 'category',
				'field'    => 'slug',
				'terms'    => $cat[0]->slug,
			],
		],
  ];
}}
@wpquery($args)
  <a class="featured-post" href="{{ the_permalink() }}">
    {{ the_title() }}
  </a>
@wpempty
@wpend