Skip to content

Instantly share code, notes, and snippets.

@abgregs
Last active March 30, 2023 19:42
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 abgregs/2d440edb0c56845b3e3e1a9f4ef26f44 to your computer and use it in GitHub Desktop.
Save abgregs/2d440edb0c56845b3e3e1a9f4ef26f44 to your computer and use it in GitHub Desktop.
A WordPress helper function that takes the ID of the current post and returns the top three related posts ranked by highest number of taxonomy terms in common with the current post.
@abgregs
Copy link
Author

abgregs commented Mar 30, 2023

@CrypticVillain Thanks for catching the issue on post limit in the query. I updated the snippet. I'll leave the original intent of the snippet to simply get the related post IDs and let the individual user worry about style and presentation as everyone has their own preference there, but thanks for including your example in the comment and I'm sure others may find it useful. Happy this helped you get most of the way there with your friend's site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment