I
I
ipatovd2018-02-26 22:12:25
PHP
ipatovd, 2018-02-26 22:12:25

How can I always get the largest [term_id] from the given array?

Array
(
    [0] => WP_Term Object
        (
            [term_id] => 49
        )

    [1] => WP_Term Object
        (
            [term_id] => 65
        )

    [2] => WP_Term Object
        (
            [term_id] => 11
        )

)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ipatovd, 2018-02-26
@ipatovd

$terms = get_the_terms( $post->ID, 'catalog');
foreach ( $terms as $term ) {
    $termID[] = $term->term_id;
}
$needTerm = max($termID);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question