Created
March 22, 2012 13:17
-
-
Save billerickson/2158296 to your computer and use it in GitHub Desktop.
Books Page Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Books LATEST | |
*/ | |
/** | |
* Modify Post Navigation | |
* @since 1.0.0 | |
* | |
* | |
* | |
*/ | |
add_filter ( 'genesis_older_link_text' , 'wps_booknavolder_filter' ); | |
function wps_booknavolder_filter ( $older_link_text ) { | |
$older_link_text = g_ent( '« ' ) . __( 'Older Books' , CHILD_DOMAIN ); | |
return $older_link_text; | |
} | |
add_filter ( 'genesis_newer_link_text' , 'wps_booknavnewer_filter' ); | |
function wps_booknavnewer_filter ( $newer_link_text ) { | |
$newer_link_text = __( 'Newer Books' , CHILD_DOMAIN ) . g_ent( ' »' ); | |
return $newer_link_text; | |
} | |
remove_action('genesis_post_content', 'genesis_do_post_content'); | |
/** | |
* Remove Genesis Post Content | |
* | |
*/ | |
add_action( 'genesis_after_post_content', 'be_list_posts' ); | |
/** | |
* List Posts | |
* | |
*/ | |
function be_list_posts() { | |
$args = array( | |
'post_type' => 'wps_book', | |
'posts_per_page' => 12, | |
'paged' => get_query_var('page') | |
); ?> | |
<div class="book-top-wrap"> | |
<div class="bookpage-intro"><?php the_content();?></div> | |
<?php | |
if ( is_active_sidebar( 'bookcat-widgets' ) ) { | |
echo '<div id="bookcat-widgets">'; | |
dynamic_sidebar( 'bookcat-widgets' ); | |
echo '<p class="return-books"><a href="'.get_bloginfo('url').'/book-store"><strong>View All Genres</strong></a></p>'; | |
echo '</div><!-- end #bookcat-widgets --></div><!-- end .book-top-wrap -->'; | |
} | |
$loop = new WP_Query( $args ); | |
if( $loop->have_posts() ): | |
echo '<div class="book-listing">'; | |
while( $loop->have_posts() ): $loop->the_post(); | |
$classes = 'book one-third'; | |
if( 0 == $loop->current_post || 0 == $loop->current_post % 3 ) | |
$classes .= ' first'; | |
echo '<div id="book-' . $loop->current_post . '" class="' . $classes . '">'; | |
if( genesis_get_custom_field('we_amazon-asin-isbn10') != '' ) { ?> | |
<div class="book-single"> | |
<div class="product_info"> | |
<?php amazon_do_shortcode('[amazon asin="' . genesis_get_custom_field('we_amazon-asin-isbn10') . '"]') ?> | |
<?php ob_start(); ?> | |
<a href="[amazon get="link"]"><img class="aligncenter" src="[amazon get="medium_image"]" /></a> | |
<div class="book-entry-title"><a href="[amazon get="link"]">[amazon get="title" length="70"]</a></div> | |
<div class="book-author">By: [amazon get="author"]</div> | |
</div><!--end .product_info --> | |
<div class="buyamazon"> | |
<form method="get" action="http://www.amazon.com/gp/aws/cart/add.html"> | |
<input type="hidden" name="AWSAccessKeyId" value="[amazon setting="access_key"]" /> | |
<input type="hidden" name="AssociateTag" value="[amazon setting="associate_tag"]" /> | |
<input type="hidden" name="ASIN.1" value="<?php echo genesis_get_custom_field('we_amazon-asin-isbn10'); ?>" /> | |
<input type="hidden" name="Quantity.1" value="1" /> | |
<input type="image" id="amazonbuy" name="add" value="Buy from Amazon.com" border="0" alt="Buy from Amazon.com" src="http://images.amazon.com/images/G/01/associates/add-to-cart.gif"> | |
</form> | |
</div><!--end .buyamazon --> | |
<?php amazon_do_shortcode(ob_get_clean()); ?> | |
</div><!--end .book-single --> | |
<?php | |
} | |
echo '</div><!-- .book -->'; | |
endwhile; | |
genesis_posts_nav(); | |
echo '</div><!-- .book-listing -->'; | |
endif; | |
wp_reset_query(); | |
} | |
add_action('genesis_after_loop', 'we_after_content'); | |
/** | |
* Add content after loop for View All Genres | |
* | |
*/ | |
function we_after_content() { | |
echo'<div><p class="return-books-footer"><a href="'.get_bloginfo('siteurl').'/book-store"><strong>View All Genres</strong></a></p></div>'; | |
} | |
genesis(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment