How do I display a tag cloud to only show tags specific to the article page?
-
I have article pages that are related to a handful of tags, but what I want to achieve is having the tag cloud only show the tags that are related to the current page. For instance, normally the tag cloud will show all the available tags, but when I am on an article page, the tag cloud should only show the one or two tags specific to the article.
I’ve tried adding this at the bottom of the functions.php file
function all_tag_cloud_widget_parameters() { $tag_ids = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) ); $args = array( 'smallest' => 10.541, 'largest' => 10.541, 'unit' => 'pt', 'format' => 'list', 'order' => ASC, 'include' => $tag_ids, 'taxonomy' => 'post_tag', 'post_type' => '', 'echo' => true, 'show_count' => 0, ); if ( $tag_ids ) { wp_tag_cloud( array( 'unit' => 'px', // font sizing choice (pt, em, px, etc) 'include' => $tag_ids, // ID's of tags to include, displays none except these ) ); } return $args; }
This does not seem to work for me, and I am not really certain where I can add the code to change the functionality of the tag cloud. The lines I should highlight are
$tag_ids = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
and
if ( $tag_ids ) { wp_tag_cloud( array( 'unit' => 'px', // font sizing choice (pt, em, px, etc) 'include' => $tag_ids, // ID's of tags to include, displays none except these ) ); }
These lines should be able to limit the tag cloud to tags that are specific to the page, but nothing changes when I put them in the functions.php file.
The page I need help with: [log in to see the link]
- The topic ‘How do I display a tag cloud to only show tags specific to the article page?’ is closed to new replies.