I know basic WordPress development. I still get confused with what functions can be used outside of the loop and inside, blah blah. But for the most part, I can handle the basic development needs of a Wordpress site. However the website I'm working on is requesting that related posts be sorted by tags and if other posts share the same tags, then the post that is newer gets displayed first in the related post section.

I'm currently filtering posts like this:

$args = array(
'tag_slug__in' => $terms,
'posts_per_page' => 1,

$terms is an array of tags that are being used by the post to help filter other posts with those same tags. At the moment if a post matches 1/5 tags of the main post and is the newest post it will display over a post that matches 5/5 tags but an older post. The older post in this case should be displayed over the newer post that has less tags matching the main post.

can someone explain to me how to do this advance filtering?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.