Guest User

Untitled

a guest
Feb 15th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <?php
  2. function getMostUsedTaxonomies($taxonomy, $fields = 'all', $orderBy = 'count', $orderDirection = 'desc', $limit = '30') {
  3. $transientName = 'mostUsedTaxonomies_'.$taxonomy.'_'.$fields.'_'.$orderBy.'_'.$orderDirection.'_'.$limit;
  4. $mainTechnologies = get_transient( $transientName );
  5. if ( $mainTechnologies === false ) {
  6. $params = array(
  7. 'taxonomy' => $taxonomy,
  8. 'hide_empty' => true,
  9. 'orderby' => $orderBy,
  10. 'order' => $orderDirection,
  11. 'number' => $limit,
  12. 'fields' => $fields
  13. );
  14. $mainTechnologies = get_terms($params);
  15. set_transient($transientName, $mainTechnologies, 60*60*24);
  16. }
  17. return $mainTechnologies;
  18. }
Add Comment
Please, Sign In to add comment