title: Create a Bootstrap card layout to display blog posts on Wordpress
body: <p>I have some HTML/CSS that I've previously used to display blog post intros on a static website. I'm now building a theme for Wordpress and I would like to use the same layout to display all of my posts within the theme. Based on <a href="https://wordpress.stackexchange.com/questions/251205/creating-custom-blog-page-template-the-right-way">this accepted answer</a> I think the best option is to create a page template (option 2 from the top answer in the link). The static layout looks like this: <a href="https://i.stack.imgur.com/uFtfs.png" rel="nofollow noreferrer">Bootstrap layout</a>.</p>
  
  <p>The HTML from the above screenshot is (just the first row of cards):</p>
  
  <pre><code>&lt;div class="row mb-2"&gt;
          &lt;div class="col-md-6"&gt;
            &lt;div class="card flex-md-row mb-4 shadow-sm h-md-250 card-left"&gt;
              &lt;div class="card-body d-flex flex-column align-items-start"&gt;
                &lt;strong class="d-inline-block mb-2 text-danger"&gt;Film&lt;/strong&gt;
                &lt;h3 class="mb-0"&gt;
                  &lt;a class="text-dark" href="#"&gt;The Last Jedi&lt;/a&gt;
                &lt;/h3&gt;
                &lt;div class="mb-1 text-muted"&gt;Sep 19&lt;/div&gt;
                &lt;p class="card-text mb-auto"&gt;Star Wars Episode VIII proved to be divisive within the fandom. How will it be remembered once the sequel trilogy has concluded?&lt;/p&gt;
                &lt;a href="#"&gt;Continue reading&lt;/a&gt;
              &lt;/div&gt;
              &lt;img class="card-img-right flex-auto d-none d-lg-block" data-src="holder.js/200x250?theme=thumb" alt="The Last Jedi" style="width: 200px; height: 250px;" src="Images/Thumbnails/The-Last-Jedi-Thumbnail.jpg" data-holder-rendered="true"&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="col-md-6"&gt;
            &lt;div class="card flex-md-row mb-4 shadow-sm h-md-250 card-right"&gt;
              &lt;div class="card-body d-flex flex-column align-items-start"&gt;
                &lt;strong class="d-inline-block mb-2 text-danger"&gt;Film&lt;/strong&gt;
                &lt;h3 class="mb-0"&gt;
                  &lt;a class="text-dark" href="#"&gt;Episode IX&lt;/a&gt;
                &lt;/h3&gt;
                &lt;div class="mb-1 text-muted"&gt;Aug 19&lt;/div&gt;
                &lt;p class="card-text mb-auto"&gt;The final chapter of the Skywalker sage is key to the future of the franchise, away from the original protagonists.&lt;/p&gt;
                &lt;a href="#"&gt;Continue reading&lt;/a&gt;
              &lt;/div&gt;
              &lt;img class="card-img-right flex-auto d-none d-lg-block" data-src="holder.js/200x250?theme=thumb" alt="The Rise of Skywalker" style="width: 200px; height: 250px;" src="Images/Thumbnails/The-Rise-of-Skywalker-Thumbnail.jpg" data-holder-rendered="true"&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
  </code></pre>
  
  <p>With a small amount of CSS:</p>
  
  <pre><code>.card-left {
      margin-left: 15%;
      margin-right: 2%;
      margin-top: 1.5%;
      margin-bottom: 1.5%;
  }
  
  .card-right {
      margin-left: 2%;
      margin-right: 15%;
      margin-top: 1.5%;
      margin-bottom: 1.5%;
  }
  </code></pre>
  
  <p>The information on the cards will need to map to WP. So from the above screenshot the coloured category (e.g. film) would be the WP category, the title the post title, the date the post date, the description a character-capped excerpt and the continue reading a link to the full post. I'd like the image to be a cropped version of the post header image, but for now am happy to exclude this part for the sake of simplicity.</p>
  
  <p>I have a very simple index.php from the Underscores starter theme that I'd like to use to create this blog template:</p>
  
  <pre><code>&lt;?php
  /**
   * Template Name: Blog Card Layout
   *
   * The template file for displaying blog posts using a Bootstrap card layout.
   */
  
  get_header();
  ?&gt;
  
    &lt;main id="primary" class="site-main"&gt;
  
      &lt;?php
      if ( have_posts() ) :
  
        if ( is_home() &amp;&amp; ! is_front_page() ) :
          ?&gt;
          &lt;header&gt;
            &lt;h1 class="page-title screen-reader-text"&gt;&lt;?php single_post_title(); ?&gt;&lt;/h1&gt;
          &lt;/header&gt;
          &lt;?php
        endif;
  
        /* Start the Loop */
        while ( have_posts() ) :
          the_post();
  
          /*
           * Include the Post-Type-specific template for the content.
           * If you want to override this in a child theme, then include a file
           * called content-___.php (where ___ is the Post Type name) and that will be used instead.
           */
  
          get_template_part( 'template-parts/content', get_post_type() );
          ?&gt;
  
          &lt;?php
  
        endwhile;
  
        the_posts_navigation();
  
      else :
  
        get_template_part( 'template-parts/content', 'none' );
  
      endif;
      ?&gt;
  
    &lt;/main&gt;&lt;!-- #main --&gt;
  
  &lt;?php
  get_sidebar();
  get_footer();
  </code></pre>
  
  <p>For reference, the template-parts/content looks like this:</p>
  
  <pre><code>&lt;?php
  /**
   * Template part for displaying posts
   *
   * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
   *
   * @package Suscito
   */
  
  ?&gt;
  
  &lt;article id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt;
      &lt;header class="entry-header"&gt;
          &lt;?php
          if ( is_singular() ) :
              the_title( '&lt;h1 class="entry-title"&gt;', '&lt;/h1&gt;' );
          else :
              the_title( '&lt;h2 class="entry-title"&gt;&lt;a href="' . esc_url( get_permalink() ) . '" rel="bookmark"&gt;', '&lt;/a&gt;&lt;/h2&gt;' );
          endif;
  
          if ( 'post' === get_post_type() ) :
              ?&gt;
              &lt;div class="entry-meta"&gt;
                  &lt;?php
                  suscito_posted_on();
                  suscito_posted_by();
                  ?&gt;
              &lt;/div&gt;&lt;!-- .entry-meta --&gt;
          &lt;?php endif; ?&gt;
      &lt;/header&gt;&lt;!-- .entry-header --&gt;
  
      &lt;?php suscito_post_thumbnail(); ?&gt;
  
      &lt;div class="entry-content"&gt;
          &lt;?php
          the_content(
              sprintf(
                  wp_kses(
                      /* translators: %s: Name of current post. Only visible to screen readers */
                      __( 'Continue reading&lt;span class="screen-reader-text"&gt; "%s"&lt;/span&gt;', 'suscito' ),
                      array(
                          'span' =&gt; array(
                              'class' =&gt; array(),
                          ),
                      )
                  ),
                  wp_kses_post( get_the_title() )
              )
          );
  
          wp_link_pages(
              array(
                  'before' =&gt; '&lt;div class="page-links"&gt;' . esc_html__( 'Pages:', 'suscito' ),
                  'after'  =&gt; '&lt;/div&gt;',
              )
          );
          ?&gt;
      &lt;/div&gt;&lt;!-- .entry-content --&gt;
  
      &lt;footer class="entry-footer"&gt;
          &lt;?php suscito_entry_footer(); ?&gt;
      &lt;/footer&gt;&lt;!-- .entry-footer --&gt;
  
      &lt;hr&gt;
  
  &lt;/article&gt;&lt;!-- #post-&lt;?php the_ID(); ?&gt; --&gt;
  </code></pre>
  
  <p>So my question is two-fold:</p>
  
  <ol>
  <li>Is it possible to re-create this layout, or something close to it?</li>
  <li>If so, where in the new page template would the Bootstrap HTML code go and how would I amend it so that it gets the relevant information from Wordpress? I'm particularly interested in how I could control the post excerpt and 'continue reading' element.</li>
  </ol>
  
  <p>Sorry for such a long post! I've been scratching my head over this one for a while. For reference my site is <a href="https://www.davidhazeel.com" rel="nofollow noreferrer">https://www.davidhazeel.com</a>.</p>