WordPress: get category posts from current post

This code snippet gets the one of the category that is linked to the current post, and then print the url link to the posts under this category.

ID );
	$cateId = 1; $cateName = '';
	$cateSize = sizeof($categories);
	if ($cateSize > 0) $cateId = $categories[0]->cat_ID;
	$catquery = new WP_Query( 'cat='.$cateId.'&posts_per_page=10' );
?>
have_posts()) : $catquery->the_post();?>
	
  • Search within Codexpedia

    Custom Search

    Search the entire web

    Custom Search