Skip to content

Instantly share code, notes, and snippets.

@rambuvn
Created February 13, 2014 02:00
Show Gist options
  • Save rambuvn/8968377 to your computer and use it in GitHub Desktop.
Save rambuvn/8968377 to your computer and use it in GitHub Desktop.
/*-----------------------------------------------------------------------------------*/
/* Question Actions
/*-----------------------------------------------------------------------------------*/
add_filter('dwqa_filter_bar','custom_dwqa_question_filter');
function custom_dwqa_question_filter( $tag_field ) {
ob_start();
?>
<div class="filter-by-tags select">
<?php
$selected = get_query_var( 'dwqa-question_tag');
if( ! $selected ) {
$question_tag_rewrite = get_option( 'dwqa-question-tag-rewrite', 'question-tag' );
$question_tag_rewrite = $question_tag_rewrite ? $question_tag_rewrite : 'question-tag';
$selected = isset($_GET[$question_tag_rewrite]) ? $_GET[$question_tag_rewrite] : 'all';
}
$selected_label = __('Select a Tag','dwqa');
if( $selected != 'all' ) {
$field = is_numeric($selected) ? 'id' : 'slug' ;
$selected_term = get_term_by( $field, $selected, 'dwqa-question_tag' );
$selected_label = $selected_term->name;
}
?>
<span class="current-select"><?php echo $selected_label; ?></span>
<ul id="dwqa-filter-by-tags" class="category-list" data-selected="<?php echo $selected_term->term_id; ?>">
<?php
//$exclude_FAQ = get_term_by( 'name', 'FAQ', 'dwqa-question_tag' );
$exclude_id = '';
// if( $exclude_FAQ ) {
// $exclude_id = $exclude_FAQ->term_id;
// }
wp_list_categories( array(
'show_option_all' => __('All','dwqa'),
'show_option_none' => __('Empty','dwqa'),
'orderby' => 'count',
'order' => 'DESC',
'taxonomy' => 'dwqa-question_tag',
'hide_empty' => 0,
'show_count' => 0,
'title_li' => '',
'hierarchical' => 0,
'exclude' => $exclude_id,
'walker' => new Walker_Category_DWQA()
) );
?>
</ul>
</div>
<?php
$tag_field = ob_get_contents();
ob_end_clean();
return $tag_field;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment