RPeraltaJr
10/6/2019 - 3:17 AM

Loop through posts

<?php 
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $args = array(
        'post_type'         => 'post',
        'posts_per_page'    => 2,
        'paged'             => $paged
    );
    $post_query = new WP_Query($args);
?>

<?php if( $post_query->have_posts() ): ?>
    <?php while( $post_query->have_posts() ): $post_query->the_post(); ?>

    <section class="posts">
        <div class="container">
            <div class="col col--title">
                <div class="box">
                    <h1 class="font-display-1">
                        <strong><?php echo the_title(); ?></strong>
                    </h1>
                    <ul class="list-inline">
                        <li><p><?php echo get_the_date(); ?></p></li>
                        <li><p>|</p></li>
                        <li><p><?php echo ucfirst(get_author_name()); ?></p></li>
                    </ul>
                </div>
            </div>
            <div class="col col--content">
                <div class="box">
                    <div class="body-copy--lg"><?php echo get_the_content(); ?></div>
                    <p class="body-copy--lg">
                        <a href="<?php echo get_the_permalink(); ?>"><strong>Read Full Article</strong></a>
                    </p>
                </div>
            </div>
        </div>
    </section>

    <?php endwhile; ?>
<?php endif; ?>

<div class="posts__pagination">
    <div class="container">
        <ul class="list-inline">
            <li><?php previous_posts_link( '< prev' ); ?></li>
            <li><?php next_posts_link( 'next >', $post_query->max_num_pages ); ?></li>
        </ul>
    </div>
</div>