Hello,
If I understand correctly, you want to create a query to display the latest 5 posts from a taxonomy? If not, can you please describe what TOP means for you?
Hello. Thank you for the answer. I want to find not the last 5 posts, but TOP5 posts wich have the biggest amout of the same taxonomys.
For example if I am in custom post “Title1”, and this post has taxonomy “keyword1”, “settings2”, “any other keyword”…
And in this page I want to print links to other TOP5 custom posts, that have the same taxonomys. Links that have the biggest amout of the same taxonomys. For example if “title2” has taxonomy “settings2” and “keyword1”, it means this custom posts have 2 same taxonomys as it has “Title1”. In this way I will get most related TOP5 links in each page.
I hope I explained normaly. 🙂
You can query for posts that either have all terms assigned, or any one of several terms. The former will return very few, if any matches. The latter will return many matches. I don’t know of any way in SQL to order posts by the most matched terms. You could post process the list in PHP to determine how many terms match for each post. Then sort the list by the count so determined.
I am writing here, because I do not know how to do it by myself. So thats is why I am asking for help. 🙂
Can some help to write that query, please? 🙂
I am in Custom Post “custom_x”, let it be “PAGE1”.
This post has few different taxonomys: keywords, hastags, videos.
So “PAGE1” has these data: {keywords:(keywords name1, another keyword); hastags:(one hastag, another, 3 hashtag)}; {videos:(https://onelyvideo.com/viddsdadfsd)}
So there are also some other “custom_x” posts, named: “ANOTHER PAGE”, “3 PAGE”, …
In “PAGE1” I want to print other TOP5 custom pages that have the same taxonomys. As more the same taxonomys it has, as more it will be in TOP. Sorting should be in the TOP.
I do not know how to write this type of query.
Taxonomy names and values are dynamic and different, so how to write a query, that gets TOP5 relates posts by taxonomy? I think it is only one query and I can get my result. But I do not know how to make that query.