Trying to create a Categorised Index (archive?) to use as my Home Page

The following code will first iterate and display all the categories with ID 2, 3 and 4. And the second loop will display all the posts within each of the category.

<?php
$_categories = get_categories( array(
            'orderby' => 'order',
            'order' => 'ASC',
            'include' => array(2,3,4) // put the category IDs here
        ) );

// Loop to display each of the Category
foreach( $_categories as $_category ) :

    $_posts = get_posts( array(
            'posts_per_page' => 6,
            'category__in' => array( $_category->term_id ),
            'ignore_sticky_posts' => 1,
            'post_status' => 'publish'
        ) );

    if( $_posts ) :

        echo '<section id="category-'. intval($_category->term_id) .'" class="category-block">';

            echo '<h1 class="category-title">'. esc_html($_category->name) .'<h1>';

            echo '<div class="category-articles">';

                // Loop to display posts of certain a category
                foreach( $_posts as $post ) : setup_postdata( $post );
                    echo '<article id="post-'. get_the_ID() .'" class="'. join( ' ', get_post_class( '', get_the_ID() ) ) .'">';
                        echo '<a href="'. get_the_permalink() .'" rel="bookmark">'. get_the_title() .'</a>';
                    echo '</article>';
                endforeach; wp_reset_postdata();

            echo '</div>';

            // A link to the Category archive
            echo '<a href="'. get_category_link( $_category->term_id ) .'" title="'. sprintf( esc_attr__( "View all posts in %s" ), $_category->name ) .'"></a>';

        echo '</section>';

    endif;

endforeach;

Templating

Page Template or Shortcode

If you want to stick with the WordPress’ default standard, then make a Page Template or a Shortcode with the code above and set a WordPress page as Front Page from Settings » Reading in admin end, and use the Page Template or Shortcode to let the code run on your front page.

Static Front Page

If you want to set a static front page, create a front-page.php in your Child theme, and add the code above in that page to let it work on your front page.

Remember
If you are changing in your theme, DON’T work on TwentySixteen, you will loose your work on the next release. Make a child theme and put your changes there.

Resources

  1. get_categories — WordPress Developer Resources
  2. get_posts — WordPress Developer Resources