biofriction-wp-theme/page-templates/homepage6posts.php

72 lines
2.1 KiB
PHP

<?php
/*
*/
/**
* Template Name: Home page 6 posts
* The template for displaying 3 post on the home page.
*
* @package Biofriction
* @since Biofriction 1.0.0
*/
get_header(); ?>
<div class="main-container">
<div class="main-grid">
<main class="main-content">
<div class="bfr_category_archive">
<?php
// https://developer.wordpress.org/reference/classes/wp_query/
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$the_query = new WP_Query( array(
'post_type'=>'post',
'post_status'=>'publish',
'paged' => $paged,
'posts_per_page' => 6
));
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php //the loop ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('bfr_post'); ?>>
<div class="bfr_post_content">
<header>
<h2 class="entry-title">
<a href="<?php the_permalink(); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
</h2>
</header>
<div class="bfr_post_thumbnail">
<?php if ( has_post_thumbnail() ) :?>
<img src="<?php echo get_the_post_thumbnail_url();?>" />
<?php else :?>
<img src="<?php echo catch_post_first_image();?>" />
<?php endif;?>
</div>
<footer>
<div class="excerpt post-excerpt">
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"></a>
<?php echo wp_strip_all_tags( get_the_excerpt(), true ); ?>
</div>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>" class="button">
Read more
</a>
</footer>
</div>
</article>
<?php //end the loop ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
</div>
<?php get_template_part( 'template-parts/navigation', 'prevnext' ); ?>
<?php else : ?>
<?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif; // End have_posts() check. ?>
</main>
</div>
</div>
<?php get_footer();