<?php
/**
 * Template part for displaying front page introduction.
 *
 * @package Ostrich Magazine
 */

// Get the content type.
$blog = get_theme_mod( 'ostrich_magazine_blog', 'cat' );
// Bail if the section is disabled.
if ( get_theme_mod( 'ostrich_magazine_blog_enable', 0 ) == 0 ) {
    return;
}

$get_content = ostrich_magazine_get_section_content( 'blog', $blog, 5  );

?>
<div id="our-blog" class="pt padding">

    <div class="blog-post-wrapper grid-view col-1 clear">
        <?php foreach ( $get_content as $content ):  ?>

        <article class="hentry">
            <div class="featured-image" style="background-image:url('<?php echo esc_url( get_the_post_thumbnail_url( $content['id'] ) ) ; ?>')">
                <a href="<?php echo esc_url( $content['url'] ); ?>" class="post-thumbnail-link"></a>
            </div>

            <div class="entry-container">
                <div class="entry-meta">
                    <span class="cat-links">
                        <?php the_category( ' ', ' ', $content['id'] ); ?>
                    </span>
                </div><!-- .entry-meta -->

                <header class="entry-header">
                    <h2 class="entry-title"><a href="<?php echo esc_url( $content['url'] ); ?>" tabindex="0"><?php echo esc_html( $content['title'] ); ?></a></h2>
                </header>

                <div class="entry-content">
                   <p><?php echo esc_html( wp_trim_words( $content['content'], 45 ) ); ?></p>
                </div>

                <div class="footer-meta">
                    <?php ostrich_magazine_posted_on( $content['id'] ); ?>
                </div><!-- .entry-meta -->
            </div><!-- .entry-container -->
        </article>
        <?php  endforeach ?>
    </div><!-- .blog-posts-wrapper -->
</div>