Created
October 30, 2013 19:12
-
-
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.
This file contains hidden or 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 | |
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