Deprecated: Return type of HM\BackUpWordPress\CleanUpIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/charlott/ourfragileplanet.com/site/wp-content/plugins/backupwordpress/classes/class-path.php on line 455
Display post listing differently if there's more than 3 in the category - Our Fragile Planet

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';
}
Scroll to Top