Last active
December 17, 2015 16:30
-
-
Save deltamualpha/5639611 to your computer and use it in GitHub Desktop.
A way to run a number of different tag queries in wordpress and then sort the results, putting the queries that match the most tags at the top.
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
$queries_array = {$query_1, $query_2, $query_n}; | |
$merged_array = array_reduce($queries_array, array_merge); | |
$uniques = array(); | |
$counter = array(); | |
foreach ( $merged_array as $current ) { | |
$counter[current->id] += $counter[current->id]; | |
$uniques[current->id] = $current; // pulls out unique only | |
} | |
arsort($counter); | |
foreach ( $counter as $id => $count) { | |
$uniques[$id]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment