How to get the last term from taxonomy?

admin2025-01-07  3

working on a scholar journal in which publisher add issues to the "issue" taxonomy assigned with articles. i need to display outside the loop a list of posts assigned only with the last issue (recently added). any help please?

update: i found a code to get the last term from a taxonomy:

$issue = get_terms('issue','orderby=none&order=DESC&number=1');
$current_issue = $issue[0]->slug;

But i couldn't find a way to use it to display a list of posts assigned only with that last term. any suggestions please?

working on a scholar journal in which publisher add issues to the "issue" taxonomy assigned with articles. i need to display outside the loop a list of posts assigned only with the last issue (recently added). any help please?

update: i found a code to get the last term from a taxonomy:

$issue = get_terms('issue','orderby=none&order=DESC&number=1');
$current_issue = $issue[0]->slug;

But i couldn't find a way to use it to display a list of posts assigned only with that last term. any suggestions please?

Share Improve this question edited Jul 29, 2015 at 13:15 Pieter Goosen 55.4k23 gold badges115 silver badges209 bronze badges asked Jul 28, 2015 at 19:05 nisrnisr 714 silver badges17 bronze badges 2
  • The code above is not very reliable, but then again, if you need a reliable system, you have to write your own as this is not an added feature by default. Anyways, use WP_Query with a tax_query to query posts from the returned term – Pieter Goosen Commented Jul 29, 2015 at 13:18
  • thanks Mr. @PieterGoosen .. but i have another question on the same issue here (wordpress.stackexchange.com/questions/196181/…) – nisr Commented Jul 31, 2015 at 10:46
Add a comment  | 

1 Answer 1

Reset to default 0

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

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

How to get the term before the last from a custom taxonomy?

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736256009a327.html

最新回复(0)