I want to have a short code to show the last 2 posts posted by the user connected in a sidebar widget or anywhere

I have read several responses about displaying posts created by the currently logged in user. However, I still can't create a short code that I can use in a widget or page to display the last 2 posts created by the current user, for example, this one.


while ( $query->have_posts() ) {