Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

EbrahemSamer's avatar

How to show related topics in blog ? PHP Native

I've posts that have column tags and stored like that (tag1, tag2, tag3)

I want in the single post page to show the related topics depends on the post tags.

How can I do this...

Forexample: I want 10 posts that have at least one of these single post tags.

0 likes
2 replies
Tray2's avatar
Tray2
Best Answer
Level 73

I would use a many to many for that instead that way the logic would be way easier.

However with your code you can explode the string into an array and then loop over the resulting array looking for matches in your table.

1 like

Please or to participate in this conversation.