Site icon Hip-Hop Website Design and Development

WordPress Child Category Display All Posts

I am creating a WordPress page where all my posts in the child categories of team are displayed in a grid. I got this working with the below code. The formatting and general layout is great however it only shows the 5 most recent posts in the child category instead of all of them. In my WordPress account I have 7 posts which should be displaying. How should I retrieve the posts so it displays them all.

                <ul class="faces">

 <?php
$categories = get_categories( 'child_of=2' );  
foreach  ( $categories as $category ) {

    echo '<div class="grid-row"><h2>'.$category->name.'</h2></div>';

    $cat_posts = get_posts( 'cat='.$category->term_id );
    $end = count( $cat_posts ) - 1;
    $i = 0;
    foreach ( $cat_posts as $post ) {
        setup_postdata( $post );
        $face = get_field( 'face' );
        $name = get_field( 'fullname' );

        if ( $i % 6 === 0 ) {
            echo '<div class="grid-row">';
        }
      echo '<div class="obj">';

        echo wp_get_attachment_image($face)
            . '<div class="name">'.$name.'</div>';

        echo '</div>';
                if ( $i % 6 === 5 ) {
            echo '</div>';
        }
               $i++;
    }
}?>
    </ul>

//css

div.grid-row {
    width: 100%;

   height: 100%;
    position: relative;
    overflow: hidden;
}
div.obj{
float: left;
    position: relative;
    padding-right: 10px;
}
.faces{
    width: 1000px;

}

REVISED TO POST BELOW:

REV FOR POST BELOW:

<?php
$categories = get_categories( 'child_of=2' );  
foreach  ( $categories as $category ) {

    echo '<div class="grid-row"><h2>'.$category->name.'</h2></div>';
    $args1 = array( 'posts_per_page' => -1, 'cat='.$category->term_id );
    $cat_posts = get_posts( $args1 );
    $end = count( $cat_posts ) - 1;
    $i = 0;
    foreach ( $cat_posts as $post ) {
    $post_category = get_the_category($post->ID);
    if($post_category->cat_name == $category->name){
        setup_postdata( $post );
        $face = get_field( 'face' );
        $name = get_field( 'fullname' );

        if ( $i % 6 === 0 ) {
            echo '<div class="grid-row">';
        }
      echo '<div class="obj">';

       echo '<div class="faceThumb">';
       echo wp_get_attachment_image($face);
       echo '</div>';
          echo '<div class="name">';
          echo $name;
          echo '</div>';

        echo '</div>';
                if ( $i % 6 === 5 ) {
            echo '</div>';
        }
        }
               $i++;

    }
}?>