Created
March 23, 2012 18:43
-
-
Save wpsitesimple/2173670 to your computer and use it in GitHub Desktop.
Genre Taxonomy 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: Genre Taxonomy | |
*/ | |
/** | |
* Modify Book Store navigation. | |
* | |
*/ | |
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; | |
} | |
/** | |
* Exclude Author Bio (WP-Biographia plugin) | |
* | |
*/ | |
add_action( 'genesis_before_content' , 'remove_author_box_page_template' ); | |
function remove_author_box_page_template() { | |
add_filter( 'wp_biographia_pattern' , 'content_only_pattern' ); | |
} | |
function content_only_pattern( $pattern ) { | |
return '%1s'; | |
} | |
/** | |
* Get Taxonomy Term and Remove Link Tags | |
* (used to display taxonomy term) | |
*/ | |
function the_simple_terms() { | |
global $post; | |
$terms = get_the_terms($post->ID,'wps_genre','',', ',''); | |
$terms = array_map('_simple_cb', $terms); | |
return implode(', ', $terms); | |
} | |
function _simple_cb($t) { | |
return $t->name; | |
} | |
// Only use pagination on custom loop | |
remove_action( 'genesis_after_endwhile', 'genesis_posts_nav' ); | |
remove_action('genesis_loop', 'genesis_do_loop'); | |
add_action( 'genesis_loop', 'we_books_loop' ); | |
/** | |
* Books Loop | |
* | |
*/ | |
function we_books_loop() { | |
$term = get_query_var( 'term' ); | |
$taxonomy = 'wps_genre'; | |
$args = array( | |
'posts_per_page' => 6, | |
'post_type' => 'wps_book', | |
'paged' => get_query_var( 'paged' ), | |
'tax_query' => array( | |
array( | |
'taxonomy' => $taxonomy, | |
'field' => 'slug', | |
'terms' => $term, | |
) | |
) | |
); | |
echo '<h1 class="entry-title">'; echo the_simple_terms(); echo '</h1>'; | |
echo '<div class="book-top-wrap">'; | |
echo '<div class="bookpage-intro">'; | |
$id=13; | |
$post = get_page($id); | |
$content = apply_filters('the_content', $post->post_content); | |
echo $content; | |
echo '</div><!-- end .bookpage-intro -->'; | |
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 -->'; | |
echo '</div><!-- end .book-top-wrap -->'; | |
} | |
global $wp_query; | |
$wp_query = new WP_Query( $args ); | |
if( $wp_query->have_posts() ): | |
echo '<div class="book-listing">'; | |
while( $wp_query->have_posts() ): $wp_query->the_post(); global $post; | |
$classes = 'book one-third'; | |
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 3 ) | |
$classes .= ' first'; | |
echo '<div id="book-' . $wp_query->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; | |
echo '</div><!-- .book-listing -->'; | |
genesis_posts_nav(); | |
endif; | |
wp_reset_query(); | |
} | |
add_action('genesis_after_loop', 'we_after_content'); | |
/** | |
* After Loop Content | |
* | |
*/ | |
function we_after_content() { | |
echo'<div class="clear"></div><div><p class="return-books-footer"><a href="'.get_bloginfo('url').'/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