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

Fatal error: Uncaught wfWAFStorageFileException: Unable to save temporary file for atomic writing. in /home/charlott/ourfragileplanet.com/site/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php:34 Stack trace: #0 /home/charlott/ourfragileplanet.com/site/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php(658): wfWAFStorageFile::atomicFilePutContents('/home/charlott/...', '<?php exit('Acc...') #1 [internal function]: wfWAFStorageFile->saveConfig('livewaf') #2 {main} thrown in /home/charlott/ourfragileplanet.com/site/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php on line 34