question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get taxonomy by slug

See original GitHub issue

In the docs (frontpage) it says:

wp.taxonomies().taxonomy( 'taxonomy_name' ).term( termIdentifier ): get the term with slug or ID termIdentifier from the taxonomy taxonomy_name

This works with the ID, but not with the slug 😦. Is this something that changed?

HOST/wp-json/taxonomies/post_tag/terms/42 works HOST/wp-json/taxonomies/post_tag/terms/sociaal-ondernemerschap doesn’t

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kadamwhitecommented, Jun 24, 2016

The “slug” query parameter is now supported by the WordPress REST API for the tags and categories endpoints. https://github.com/WP-API/WP-API/issues/924

0reactions
kadamwhitecommented, Jan 21, 2016

In the intervening year, this has been broken again by the v2 beta upgrades: WP-API/WP-API#924 identifies that filter is not currently supported on the /categories or /tags endpoints.

WP-API/WP-API#2065 has been opened to identify whether this will ever be reinstated; in the meantime, #126 will add a demonstration of using the ?search parameter to slightly more efficiently retrieve a specific term by slug (basically the same “get them all and search for the one you want in the response” approach detailed above, but with less overhead due to the narrowing effect of ?search=the-slug).

Read more comments on GitHub >

github_iconTop Results From Across the Web

get_term_by() | Function - WordPress Developer Resources
get_term_by() returns a single WP_Term object. Because of core changes from v4.1 – 4.3, it's now possible for multiple terms to match the...
Read more >
How to get a taxonomy term name by the slug?
The function you are looking for is get_term_by . You would use it as such: <?php $term = get_term_by('slug', 'my-term-slug', ...
Read more >
Wordpress get taxonomy name with slug - Stack Overflow
WordPress does provide a function to get the taxonomy information from its slug. $taxonomy_details = get_taxonomy( $slug );.
Read more >
How to Create Custom Taxonomies in WordPress - WPBeginner
Your first step is to create a slug for the taxonomy. This slug is used in the URL and in WordPress search queries....
Read more >
Get The Slug and Name From Custom Taxonomy | John Hartley
$terms = get_the_terms( $post ->id, 'custom-taxonomy' ); // get an array of all the terms as objects. $term_slug = array (); // save...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found