Created
October 27, 2012 21:04
-
-
Save jshakes/3966252 to your computer and use it in GitHub Desktop.
Author taxonomy
This file contains 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
function register_taxonomies(){ | |
register_taxonomy('author', array('post'), | |
array( | |
'labels' => array( | |
'name' => __( 'Authors' ), | |
'singular_name' => __( 'Author' ) | |
), | |
'show_ui' => true, | |
'query_var' => true | |
) | |
); | |
register_taxonomy('book', array('post'), | |
array( | |
'labels' => array( | |
'name' => __( 'Books' ), | |
'singular_name' => __( 'Book' ) | |
), | |
'show_ui' => true, | |
'query_var' => true | |
) | |
); | |
} | |
add_action( 'init', 'register_taxonomies', 0 ); | |
/* Output */ | |
$authors = get_the_terms($post->ID, 'author'); | |
foreach($authors as $author){ | |
echo '<a href="' .get_term_link($author->slug, $taxonomy) .'">'.$author->name.'</a>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment