WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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.