Last active
August 29, 2015 13:57
-
-
Save astockwell/9360602 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Reference | |
* | |
* Term object keys: | |
* [term_id, name, slug, term_group, term_taxonomy_id, taxonomy, description, parent] | |
* | |
*/ | |
/* | |
* Scope: Global | |
*/ | |
// Get all terms in a taxonomy | |
$terms = get_terms( 'taxonomy (string|array)', array('orderby' => 'menu_order') ); | |
// Get a term object from id/slug/name | |
$term = get_term_by( 'field ("id"|"slug"|"name")', 'value (string|int)', 'taxonomy (string)' ); | |
// Get term archive url | |
$url = get_term_link( $term (term object|term ID|term slug), $taxonomy ); | |
/* | |
* Scope: Post | |
*/ | |
// Get post terms | |
$terms = wp_get_post_terms( $post->ID, 'taxonomy (string|array)' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment