0

This code displays the last term added to a taxonomy "issue" which i use to automatically display a link toward my current issue:

$args = array( 'hide_empty=0' );
$terms = get_terms( 'issue', 'orderby=id&order=DESC&number=1' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
    $count = count( $terms );
    $i = 0;
    $term_list = '<p class="arc">';
    foreach ( $terms as $term ) {
        $i++;
        $term_list .= '<a href="' . get_term_link( $term ) . '" title="' . sprintf( __( 'View all post filed under %s', 'my_localization_domain' ), $term->name ) . '">(' . $term->name . ')</a>';
        if ( $count != $i ) {
            $term_list .= ' </p> ';
        }
        else {
            $term_list .= '';
        }
    }
    echo $term_list;
}

I need to display the term before the last to show automatically the link of previous issue of my publications. Any suggestions please?

1 Answer 1

0

If you change the paramter "number" to 2 in the line :

$terms = get_terms( 'issue', 'orderby=id&order=DESC&number=1' );

You'll get the last 2 terms, so the 2 you want ?

1
  • thanks for your response. no i need just the second term. e.g. issue terms = VOL7, VOL8, VOL9. i need the code to display VOL8. only.
    – nisr
    Jul 31, 2015 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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