Displaying posts from current category WordPress without plugin

<?php	query_posts('cat=3'); // point your category number instead of 3
while (have_posts()) : the_post();?>
<?php echo '<div class="blos">'; ?>
	<div class="thumbnail"><?php echo get_the_post_thumbnail(); ?></div>
	<div>
		<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
		<?php the_content(); 
		echo '</div></div>';
		endwhile;
		wp_reset_query();
		?>

This method helps you show Advanced Custom fields in post content and also prevents jQuery conflicts if you need to show posts from category as a tab of WordPress tabbed navigation.

Another way

You can also add and setup recent posts from chosen category in edit page visual editor. Just press plus button and type latest posts in the search form. Then in the right column choose category name and fill all the form fields needed. That’s it. You can edit HTML layout of this block in wp-includes/blocks/latest-posts.php

(Visited 11 times, 1 visits today)

Leave a comment

Your email address will not be published. Required fields are marked *