Showing custom content from specific function in a page

I have a custom php function that returns some text that I would like to show in a specific wordpress page
The fastest idea that comes to my mind, is to return that content through a shortcode and put that shortcode in the given page.

But for the sake of learning better approaches I’ve been thinking that this method, performance-wise, is very poor, so maybe there is a better way to show this content the same way a shortcode do, but straight from code.

Let’s say that the content is shown in the page “My Custom Page” with URL https://example.com/my-custom-page (lets say that the page wp_post id is number 50 in case this helps for query purposes)

Any ideas on how to improve this?
Or shall I stick to the shortcode method?

I’m also thinking on hardcoding in the template the function as page-template (something like page-my-custom-page.php) but still I’m not sure if there is an additional more efficient way, that is theme agnostic.

Xin chào các bạn và quý Thầy Cô. Hãy nhập từ khóa mình muốn vào ô tìm kiếm trên Website để tìm kiếm mọi thứ hoặc trên google các bạn hãy nhập từ khóa + dethihsg247.com để tìm kiếm các bài viết của chúng tôi nhé.
  • Hiện tại chúng tôi có hơn 25 nghìn bài văn mẫu các thể loại.
  • Kho tài liệu, đề thi học sinh giỏi các lớp vô cùng phong phú.
  • Mỗi ngày cập nhật hơn 100 đề thi chất lượng từ các website bán tài liệu lớn.

Tải đề thi VIP với giá siêu rẻ tại Vip.Dethihsg247.Com