Last active
August 29, 2015 14:08
-
-
Save damianwajer/01df307da66db6ed8bad to your computer and use it in GitHub Desktop.
[WordPress] Taxonomy 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 | |
/** | |
* Taxonomy template | |
* @link http://codex.wordpress.org/Class_Reference/WP_Query | |
*/ | |
// Protect against arbitrary paged values | |
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1; | |
$taxonomy = get_query_var( 'taxonomy' ); | |
$term = get_query_var( 'term' ); | |
// The Query | |
$the_query = new WP_Query( array( | |
'post_status' => 'publish', | |
'tax_query' => array( | |
array( | |
'taxonomy' => $taxonomy, | |
'field' => 'slug', | |
'terms' => $term, | |
), | |
), | |
'posts_per_page' => get_option( 'posts_per_page' ), | |
'paged' => $paged, | |
) ); | |
if ( $the_query->have_posts() ) : | |
while ( $the_query->have_posts() ) : $the_query->the_post(); | |
get_template_part( 'partials/content', 'teaser' ); | |
endwhile; | |
else : | |
get_template_part( 'partials/content', 'none' ); | |
endif; | |
/* Restore original Post Data */ | |
wp_reset_postdata(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment