How to display random posts in custom page in wordpress

How to display random posts in custom page in wordpress

This is amazing requirement from one of my client. In the requirement, they want to display random posts in one of the custom page in their website. So I have done some R & D for it but not found exact article. So I have made my own way. Each time you refresh custom page, you will get different posts.

Step : First of all, you have to create custom page template. Then you have to paste below code in it.