Skip to content

Instantly share code, notes, and snippets.

@josephhinson
Created November 5, 2013 13:55
Show Gist options
  • Select an option

  • Save josephhinson/7319324 to your computer and use it in GitHub Desktop.

Select an option

Save josephhinson/7319324 to your computer and use it in GitHub Desktop.
Taxonomy archive page for some reason, WordPress doesn't seem to like the taxonomy archive by default, so I usually end up creating this page, it's a bit of a hack, but it works. Name it taxonomy-your_taxonomy.php -- obviously edit as needed, but the code should work universally...
<?php get_header(); ?>
<div class="container blog content">
<div class="row">
<div class="span8 entry">
<div class="headline">
<?php
$value = get_query_var($wp_query->query_vars['taxonomy']);
$cat = get_term_by('slug',$value,$wp_query->query_vars['taxonomy']); ?>
<h1><?php echo $cat->name; ?></h1>
<?php $loop = new WP_Query(array(
'posts_per_page' => '-1',
'orderby' => 'menu_order',
'order' => 'ASC',
'post_type'=>'resources',
'taxonomy'=>'type',
'term' => $cat->slug)
); ?>
</div>
<?php $c = 1; ?>
<div class="resource-box">
<?php
$c = 1;
if ($loop->have_posts()): ?>
<?php while ($loop->have_posts()) : $loop->the_post(); ?>
<div class="resource post-wrap">
<?php if (has_post_thumbnail($post->ID)) :
echo get_the_post_thumbnail( $post->ID, 'book-thumb', array('title' => $post->post_title, 'class' => 'alignleft'));
endif; ?>
<div class="resource-content">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
</div>
</div>
<?php $c++; endwhile; endif; ?>
</div><!--END resource-box-->
<?php
?>
</div><!--end span7 -->
<?php get_sidebar(); ?>
<div class="clr"></div>
</div><!--end row -->
</div><!--end container -->
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment