Skip to content

Instantly share code, notes, and snippets.

@jshakes
Created October 27, 2012 21:04
Show Gist options
  • Save jshakes/3966252 to your computer and use it in GitHub Desktop.
Save jshakes/3966252 to your computer and use it in GitHub Desktop.
Author taxonomy
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