the recommended way is:
<?php
$query = new WP_Query('category_name=Category&posts_per_page=4');
if($query->have_posts()) : while($query->have_posts()) : $query->the_post();
if (has_post_thumbnail()) {
?>
<a href="https://wordpress.stackexchange.com/questions/162985/<?php the_permalink(" ') ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a>
<?php
}
?>
<h2><a href="https://wordpress.stackexchange.com/questions/162985/<?php the_permalink(" ') ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<?php
the_excerpt(); // or the_content(); for full post content
endwhile;endif;
?>