Skip to content

Instantly share code, notes, and snippets.

@jlengstorf
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlengstorf/c6d8afb5909a10eb85c0 to your computer and use it in GitHub Desktop.
Save jlengstorf/c6d8afb5909a10eb85c0 to your computer and use it in GitHub Desktop.
A simple way to load related posts using WordPress categories.
<?php
// Put this inside the loop
$categories = wp_get_post_categories(get_the_ID(), array('number'=>1));
$related_posts_id = get_the_ID();
$related_posts_cats = $categories;
get_template_part('layouts/related-posts');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment