Skip to content

Instantly share code, notes, and snippets.

@raideus
Created October 30, 2013 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raideus/7238372 to your computer and use it in GitHub Desktop.
Save raideus/7238372 to your computer and use it in GitHub Desktop.
Function which generates a list of links corresponding to each selected term in a search query. Requires WP Advanced Search.
<?php
function gs_selected_criteria() {
$terms = array();
$search = new WP_Advanced_Search();
$taxonomies = $search->selected_taxonomies;
if ($taxonomies) {
$output = '<div class="selected-terms">SELECTED CRITERIA</div>';
foreach ($taxonomies as $taxonomy => $terms) {
foreach ($terms as $term) {
$tax = get_term_by('slug',$term,$taxonomy);
$name = $tax->name;
$output .= '<a rel="'.$term.'" class="selected-term">'.$name.'</a>';
}
}
return $output;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment