function post_loop()
{
$arg = array(
'post_type' => 'post',
'posts_per_page' => -1,
);
$postPost = new WP_Query($arg);
?>
<div id="mainPost" class="row">
<?php if ($postPost->have_posts()) : ?>
<?php while ($postPost->have_posts()) : ?>
<?php $postPost->the_post();
$content= get_the_content();
?>
<div class="col-md-6">
<div class="singlePost">
<?php the_post_thumbnail( 'full', array( 'class' => 'postImg' ) ); ?>
<div class="contentArea">
<h2><?php the_title(); ?></h2>
<p><?php echo substr($content, 0, 180); ?>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php
wp_reset_postdata();
}
add_shortcode('mainPost', 'post_loop');
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter