Related post without plugin for custom post types

Welcome, actually if to show me relevant articles you can use plugins

This helps you to reduce a lot of effort

However, as I see, you want to display related articles on how to be able to optimize website loading speed

I do not suggest you use the API functions outside of wordpress, but for me it is a good solution.

I can give you a solution as follows:

  • You create a custom field for the post – _title (content is the title of the article)

  • You need INDEX for the table wp_postmeta (meta_value field)

  • ADD You fulltext for this field

then use the SQL statement (not the wordpress API) to query related articles under the title of the article

Using Fulltext search with the meta_value have relatively good speed.

Wish you success