• minix741

    (@minix741)


    Hello,

    Can someone help with full PHP code, how to get TOP5 post with similar taxonomys?
    If I am in custom_page_x and in that page I want to print TOP5 who has the biggest amout of the same taxonomys. As I understand I can put this code in PHP file custom-page-x.php and it will show TOP5 posts. But I do not know how to make that query. I would like to get TOP5 posts links, title and one specific taxonomy’s info.

    I think here should be some MYSQL query. THANK YOU. 🙂

    • This topic was modified 5 years ago by minix741.
Viewing 7 replies - 1 through 7 (of 7 total)
  • BakemyWP

    (@bakemywp)

    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?

    Thread Starter minix741

    (@minix741)

    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. 🙂

    Moderator bcworkz

    (@bcworkz)

    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.

    Thread Starter minix741

    (@minix741)

    I am writing here, because I do not know how to do it by myself. So thats is why I am asking for help. 🙂

    Thread Starter minix741

    (@minix741)

    Can some help to write that query, please? 🙂

    Thread Starter minix741

    (@minix741)

    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.

    Thread Starter minix741

    (@minix741)

    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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Get TOP5 post with similar taxonomys’ is closed to new replies.