Translated from our Japanese archive. Dates, product names and examples reflect the original article; this is not an updated product or service recommendation.

Displaying posts

This example uses a category slug together with Bootstrap to display four posts. It is a pattern I use often.

<?php query_posts(‘category_name=news&posts_per_page=4′); ?>
<?php if(have_posts()): ?>
<?php while(have_posts()): the_post(); ?>
<div class=”ttl_underline mb10 pb10 clearfix”>
<div class=”col-md-4″><?php the_post_thumbnail(‘thumbnail’); ?></div><div class=”col-md-8″><h4 class=”font20″><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></h4><br /><p><?php echo mb_substr(strip_tags($post-> post_content),0,80); ?></p></div>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>

Double Factory

About the author

Double Factory

Designer, web consultant and sales representative. Former part-time lecturer at the University of Electro-Communications, with 15 years of web production experience as described in the original profile. Gained early experience at a production company in New York. Studies web production to deliver results. Representative Director of Double Factory.

Published: 2022/3/28    Updated: 2024/8/18