Shortcodes are the power of the wordpress. You can simply create shortcodes and call it via the do_shortcode function or on pasting it on editor. For adding a shortcode, you ned to use the hook add_shortcode. We are going to share the script for shortcode creation.
In above example we are showing posts by customizing the number of the post to show. We created shortcode named mytest and passing attribute posts to customize the number of the post to show. You can call the shortcode in post editor like this