Custom Book Reviews Archive Page

I wanted an archive page for my book reviews that showed, for each book, its front cover and an excerpt of the review.

"Book Reviews Custom Archive Page"


/**
* Template Name:  Book Reviews Template
* Description:  Used as a page template to show page contents, followed by a loop
* through the Book Review (book-reviews) Category
*/

add_action('genesis_loop', 'zoia_book_reviews_loop');

function zoia_book_reviews_loop() {

    $args = array(
        'category_name' => 'book-reviews',  // category slug
        'order_by' => 'post_date',
        'order' => 'DESC',
        'posts_per_page' => '10',
    );

    $loop = new WP_Query($args);

    if($loop->have_posts()) {

        while ($loop->have_posts() ): $loop->the_post();
             echo '
'; echo '
'; if(has_post_thumbnail()) { echo ''">'; the_post_thumbnail('medium'); echo ''; } else { echo ' '; } echo '
'
; $summary = get_the_excerpt(); $summary = str_replace('Buy from Amazon', '', $summary); echo '
'; echo '

'">' . get_the_title() . '

'
; echo '

' . $summary . '

'
; echo '
'
; echo '
'
; endwhile; } wp_reset_postdata(); } genesis(); ?>

Join my free newsletter and receive updates directly to your inbox.