Related Customs posts

admin2025-04-22  0

Maybe someone can help to make related posts with custom posts type? I am stuck with that... Code is here:

For example:

We are in current post:

ID | title | cust_category | cust_names | cust_settings

1 | X1 | cat1, cat3 | name8 | set1, set5

And we have customs posts:

ID | title | cust_category | cust_names | cust_settings

2 | X4 | cat1 | name9 | set2

3 | X1 | cat1, cat3 | name9 | set5

4 | X8 | cat12 | name12 | set12

So related posts to current post (ID = 1) will be:

ID 3 and ID 2.

  • ID3 is the most related, because it has the same values - X1, cat1, set5 (related 3 values).

  • ID 2 is also related by one value - cat1.

Or you can see this explanation in image:

Maybe someone can help to make related posts with custom posts type? I am stuck with that... Code is here: https://pastebin/zRVjuMBn

For example:

We are in current post:

ID | title | cust_category | cust_names | cust_settings

1 | X1 | cat1, cat3 | name8 | set1, set5

And we have customs posts:

ID | title | cust_category | cust_names | cust_settings

2 | X4 | cat1 | name9 | set2

3 | X1 | cat1, cat3 | name9 | set5

4 | X8 | cat12 | name12 | set12

So related posts to current post (ID = 1) will be:

ID 3 and ID 2.

  • ID3 is the most related, because it has the same values - X1, cat1, set5 (related 3 values).

  • ID 2 is also related by one value - cat1.

Or you can see this explanation in image:

Share Improve this question asked Jul 22, 2019 at 17:23 Please helpPlease help 1
Add a comment  | 

1 Answer 1

Reset to default 0

P.S. In this project I use ONLY the same custom post type. No simple posts and other. Just "custom_post_name" customs posts. Nothing else. I am trying to make it work about few weeks. Please help me. As I understand I need only a good query and that is it. I am very beginner in WP.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745305057a295489.html

最新回复(0)