Community Forums › Forums › Archived Forums › General Discussion › Tag Cloud Issue
Tagged: tag cloud
- This topic has 6 replies, 3 voices, and was last updated 9 years, 1 month ago by
eventspanda.
-
AuthorPosts
-
January 28, 2016 at 7:31 am #177723
Mark-C
MemberHi All,
On my previous installation of WordPress 4.3.2 / Genesis 2.2.3, i setup a tag cloud in the sidebar. Only those tags associated to the post were displayed (using code below)
I was able to style the heading etc.add_filter('widget_tag_cloud_args','single_post_tag_cloud_tags'); function single_post_tag_cloud_tags($args) { if ( is_single() ) { global $post; $post_tag_ids = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) ); $args = array('include' => implode(',',$post_tag_ids)); $args['largest'] = 12; //largest tag $args['smallest'] = 12; //smallest tag $args['format'] = 'list'; //ul with a class of wp-tag-cloud } return $args; }
Issue
Having updated to WordPress 4.4.1, all i see is the tags. Title and styling is lost.February 5, 2016 at 5:36 am #178368Mark-C
MemberHi All,
I wonder if anyone has experienced Tag Cloud issues following on from Worpdress 4.3.2.
As previously mentioned along with the code, I was able to display all tags associated to a single post in a list form along with styling elements. Now all styling elements are lost. If on the other hand I remove the above code then I get the traditional tag cloud appearing with style elements.Does anyone know how to display only the tags associated to a single post, whilst having the freedom to style the tag cloud widget?
Thanks
Mark CFebruary 6, 2016 at 12:31 pm #178472Christoph
MemberHi,
a link to the website would be helpful.
I guess the title is still set in the tag widget?
February 7, 2016 at 3:28 am #178502Mark-C
MemberHi Christoph,
My site is on a localhost.
Feel free to give this a test run to see my point.
Install WP4.41 or higher, Genesis Framework, Genesis Sample Theme.
On the Hello World Post create a couple of tags and update.
Drill to Appearance | Widget | Primary Sidebar and add a Tag Cloud Widget. Give the Tag Cloud a title 'Blah Blah Blah'Display page in Firefox or Chrome and inspect element for the tag cloud ... all good!
Now,
add the below code into functions.php.add_filter('widget_tag_cloud_args','single_post_tag_cloud_tags'); function single_post_tag_cloud_tags($args) { global $post; $post_tag_ids = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) ); $args = array('include' => implode(',',$post_tag_ids)); $args['largest'] = 12; //largest tag $args['smallest'] = 12; //smallest tag $args['format'] = 'list'; //ul with a class of wp-tag-cloud return $args; }
Whilst the tag cloud is in a list format, all ability to format has been lost ... inspect tag cloud using inspect element.
Thank You
Mark
February 12, 2016 at 11:59 am #178907Christoph
MemberHi Mark,
sorry I either missed the notification that you responded to the topic or I didn't get one...
Use this code instead.add_filter('widget_tag_cloud_args','single_post_tag_cloud_tags'); function single_post_tag_cloud_tags($args) { global $post; $post_tag_ids = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) ); $my_args = array( 'include' => implode(',',$post_tag_ids), 'largest' => 12, //largest tag 'smallest' => 12, //smallest tag 'format' => 'list', //ul with a class of wp-tag-cloud ); $args = wp_parse_args( $args, $my_args ); return $args; }
February 13, 2016 at 6:21 am #178957eventspanda
MemberThanks for the code dear! I have the same problem after wordpress theme updation.
February 14, 2016 at 4:00 am #179005Mark-C
MemberHi Christoph,
Your script works a treat.
Thank you so much for help and support.One happy bunny,
Mark C
-
AuthorPosts
- The topic ‘Tag Cloud Issue’ is closed to new replies.