• knoppys

    (@knoppys)


    Good morning

    I created my own plugin. Just something for listing all sub categories including posts and permalinks of a given parent category.

    Problem is it only seems to be outputting 5 posts per categpry.

    I dont think theres anything in the code that limits the output to 5 posts, can someone just put my mind at rest for me and tell me im right.

    public function widget( $args, $instance ) {
    		if( $c = get_category(@$instance['category_id']) ){
    
    			foreach(get_categories(array(
    				"child_of"	=> $c->cat_ID
    
    			)) as $childCat){
    
    				echo '<div class="container">';
    				echo('<h2 class="widgettitle">'.$childCat->name.'</h2>');
    				echo '<ul>';
    
    				foreach( get_posts('cat='.$childCat->term_id) as $p) {
    					echo('
    						<li>
    							<a href="'.get_permalink($p->ID).'">'.$p->post_title.'</a>
    						</li>
    					');
    				}
    				echo '</ul>';
    				echo "</div>";
    
    			}
    		}
    
    	}
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    get_posts() defaults to 5 posts per page unless you supply a ‘posts_per_page’ argument stating otherwise.

Viewing 1 replies (of 1 total)
  • The topic ‘Plugin Code does nto list all my posts.’ is closed to new replies.