将搜索结果设置为仅显示帖子

I'm using a custom Wordpress theme. When I try a search on my website, it redirects me to the search.php. The problem is that it shows not only the posts, but also the pages and the events from the plugin "The Events Calendar". Which is bad because they don't align correctly and appear one onto another. I think edit it to show everything correctly would be harder.

So I would like my search results to show only the posts. I'm not good in PHP but I think this is the part of code that need to be changed.

<div class="content<?php if($bpxl_goblog_options['bpxl_layout'] == 'c_layout' || $bpxl_goblog_options['bpxl_layout'] == 'gs_layout' || $bpxl_goblog_options['bpxl_layout'] == 'sg_layout' || $bpxl_goblog_options['bpxl_layout'] == 'g_layout') { echo ' masonry masonry-home'; } ?>">
        <?php
            if (have_posts()) : while (have_posts()) : the_post();

            get_template_part( 'content', get_post_format() );
        ?>
        <?php endwhile; else: ?>
            <div class="post">
                <div class="single-page-content error-page-content">
                    <p><strong><?php _e('Rien à afficher'); ?></strong></p>
                    <?php get_search_form(); ?>
                </div><!--noResults-->
            </div>  
        <?php endif; ?>
    </div><!--content-->

Full search.php code here https://jsfiddle.net/jzx4evy9/

Any ideas on what need to be changed to only show the posts ?

You can use the following code in functions.php to exclude the page result

function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}

add_filter('pre_get_posts','SearchFilter');