Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to get the min and max values from a taxonomy, but my code is returning all taxonomies:

function get_years ($taxonomies, $args){
$hlterms = get_terms($taxonomies, $args);
foreach($hlterms as $term){
    $term_taxonomy = $term->year;
    $output .= $term->name;
} return $output;
}
$taxonomies = array ('year');
$args = array ('hide_empty'=>true);
$year = get_years($taxonomies, $args);
echo min(array($year));

What I'm doing wrong?

Thanks! Daniel

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Not sure but try this:

  function get_years ($taxonomies, $args){
      $output = array();
      $hlterms = get_terms($taxonomies, $args);
      foreach($hlterms as $term){
           $term_taxonomy = $term->year;
           array_push($output, $term->name);
     } return $output;
  }

$taxonomies = array ('year');
$args = array ('hide_empty'=>true);
$year = get_years($taxonomies, $args);
echo min($year); 
share|improve this answer
    
Thanks Eyal! You rock!! –  Daniel Jun 15 '12 at 2:09
    
your welcome :) –  Eyal Jun 15 '12 at 2:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.