WordPress is all about posts and showing posts is possible with the help of loop. Though it looks like a simple php loop it is abit different since we are talking about a WordPress loop.
<?php
$args = array(
'posts_per_page' => '3',
'order' => 'DESC',
'orderby' => 'date',
'cat' => -17, // - indicates the category that is not to be included
'cat' => 35 // - indicates the category to be included
//if no cat element present then all the post will enter the loop
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
?>
<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>"/>
<li class="item">
<a href="<?php the_permalink($post->ID); ?>"><?php echo get_the_title($post->ID); ?></a>
</li>
<?php
}
}
wp_reset_postdata();
?>