I'm trying to get a list of custom taxonomy terms by date (or possibly slug). What I need is the NEWEST term and it's permalink in a custom taxonomy. I've been trying the code below but it's returning the same term over and over again. The goal is to generate a link to the archive page for the newest term in this taxonomy, which happens to be a bunch of journal editions; so a link to the "Latest Edition."
// latest edition
$taxonomies = array(
'jjm_editions'
);
$args = array(
'orderby' => 'date',
'order' => 'DSC',
'hide_empty' => true,
'number' => '3'
);
$terms = get_terms($taxonomies, $args);
foreach ( $terms as $term ) {
$term_link = get_term_link( $term );
if ( is_wp_error( $term_link ) ) {
continue;
}
echo '<a href="' . esc_url( $term_link ) . '">' . $term->name . '</a>';
}
Even if I change ASC to DESC, I always get the first edition.
Edit: I know "number" should be '1'. I have it at three to see what it would output. It still only outputs one term, Edition 6.
date
isn't a valid value fororderby
, taxonomy terms have no date.hide_empty
set totrue
will only return terms with posts.