I’m trying to use tags to create a list of cross references for each post and want the tag description to show next to the tag and/or as the title attribute for the hyperlink so the description shows when a visitor holds the cursor over the link.
Using the TwentyTen theme I have located the code in functions.php and amended it as below:
function twentyten_posted_in() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list( $before = '<br /> <br />' , $sep = ' here'.'<br /><br />' , $after = '<br />' );
if ( $tag_list ) {
$posted_in = __( 'Cross Reference %2$s. ', 'twentyten' );
}
// Prints the string, replacing the placeholders.
printf(
$posted_in,
get_the_category_list( ', ' ),
$tag_list,
get_permalink(),
the_title_attribute( 'echo=0' )
);
}
endif;
As you can see I’ve changed the heading to say Cross Reference and by adding breaks I have a list of tags rather than a paragraph. I’ve identified where I want the Tag Description to go with the word “here”.
I thought it would be as simple as adding tag_description() but that didn’t work. If I put a number in the brackets, e.g. tag_description(5) it displays the tag description in the correct place, but of course all the tags have the wrong description.
Help!
Thanks
Ian.
Use
get_the_terms()
and create a custom array:Sample usage for the
functions.php
: