-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive-books.php
40 lines (37 loc) · 1.48 KB
/
archive-books.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/*
Template Name: Books Archive
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
?>
<?php get_header(); ?>
<?php get_template_part('template-parts/books-pub-hero'); ?>
<section class="container" style="max-width: 900px">
<?php
//get_posts to retrieve an array of posts
$posts = get_posts( array(
'post_type' => 'books'
)
);
?>
<?php //loop through each array object to get the thumbnail ?>
<?php foreach($posts as $post) : ?>
<div class="row my-5">
<div class="col-xl-4 text-center mb-5 mb-xl-0">
<a href="<?php echo get_permalink($post->ID);?>" target="_blank">
<img src="<?php echo get_the_post_thumbnail_url($post->ID, '')?>" alt="">
</a>
</div>
<div class="col-xl-8 d-xl-flex flex-column justify-content-xl-center text-xl-start text-center">
<a href="<?php echo get_permalink($post->ID);?>" target="_blank"><h2><?php echo get_the_title($post->ID); ?></h2></a>
<p><?php echo get_the_excerpt($post->ID); ?></p>
<a class="btn my-1 mx-xl-0 mx-auto" style="max-width: 200px;" href="<?php echo get_permalink($post->ID);?>">View Book</a>
</div>
</div>
<?php endforeach; ?>
</section>
<?php get_template_part('template-parts/contact') ?>
<?php get_template_part('template-parts/cta'); ?>
<?php get_footer(); ?>