Skip to content

Instantly share code, notes, and snippets.

View bananadesign's full-sized avatar

Dave McCourt bananadesign

View GitHub Profile
<?pjp
function banana__query_modifications($query) {
if ($query->is_main_query() && get_query_var('post_type') == 'faqs') {
$query->set('posts_per_page', -1);
$query->set('orderby', 'taxonomy');
$query->set('order', 'DESC');
}
<ul class="faqs accordion">
<?php $cat_name = null; while (have_posts()) : the_post(); ?>
<?php $terms = get_the_terms($post->ID, 'categories');
if ($terms && !is_wp_error($terms)) :
if ($cat_name != $terms[0]->name) :
$cat_name = $terms[0]->name; ?>
<h2><?php echo $cat_name; ?></h2>
<?php endif; ?>