Display post listing differently if there’s more than 3 in the category

Basically I just wanted to display only titles with a link in a page sidebar for posts in a category where there were more than three but I wanted to show the full content for a category where there were less than three.

It’s easy to do really.

$args = array( 'numberposts' => -1, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"rand", 'cat' => 10 );
$postslist = get_posts( $args );
if(count($postslist)>3){
	echo 'something';
}
else{
 echo 'something else';
}

Leave a Reply

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