Display a list of posts corresponding to a category

As an alternative, consider using get_posts()?

get_posts()

It will require other changes to your code but you can easily create a query to include Categories, and then foreach through the results.

Update:
Here’s an equivalent to your code written with get_posts(). Take a copy of your own code first but the below would replace it all. Note the Category ID in the arguments – this is what you need to change to suit your needs.

get_posts() is a much simpler function for this kind of use case than WP_Query but is less flexible if you want complex queries.

<?php
$args = array(
  'numberposts' => -1,
  'category' => 1 //REPLACE THIS NUMBER WITH YOUR CATEGORY ID!
);

$all_posts = get_posts( $args );

if (count($all_posts) > 0) : ?>

<ul>
<?php 
    foreach ( $all_posts as $post ) : ?>
        <li class="sub-menu"> 
            <a href="#" class="exposition"  data-id="<?php _e($post->ID);?>">
                <?php _e($post->post_title);?>
            </a>
            <ul>
                <li>
                    <?php _e($post->post_content);?>
                </li>
            </ul>
        </li>
        
        <?php 
    endforeach;
?>
</ul>