Show current user posts only

<?php
    $query = new WP_Query([
        'author' => get_current_user_id(),
    ]);

while ( $query->have_posts() ) {
    $query->the_post();
    the_title();
}
    wp_reset_postdata();
?>

In the example above we are using WP_Query look on the reference guide for additional parameters such as different post types like if you want to get only pages, posts or custom post types, as well as the number of elements to be displayed.

Also be aware of the usage of wp_reset_postdata as the example above uses $query->the_post()

Note: If you use the_post() with your query, you need to run wp_reset_postdata() afterwards to have template tags use the main query’s current post again.`

You can also break the code above to add additional HTML tags in between each like:

while( $query->have_posts() ) : $query->the_post(); 
?>
<h2><?php the_title(); ?><h2>
<div><?php the_content(); ?>
<?php endwhile; wp_reset_postdata(); ?>

The example above uses get_current_user_id which assumes there’s a user logged in as it returns zero if no user is logged in you can use some logic around that to display different data in that scenario.