I want to add title and alt attributes to links in the WordPress tag cloud widget but I don't know what to do. Can someone help with this? I've looked at the /wp-includes/widgets/class-wp-widget-tag-cloud.php file. Of course I failed.

The code block:

<div id="tag_cloud-4" class="widget widget_tag_cloud">
<h4 class="widget-title h6"><span>Tag Cloud Title</span></h4>
<div class="tagcloud">

<a href="https://example.com/content1/" class="tag-cloud-link tag-link-5 tag-link-position-1" style="font-size: 8pt;" aria-label="content1">content1</a>

<a href="https://example.com/content2/" class="tag-cloud-link tag-link-2 tag-link-position-2" style="font-size: 22pt;" aria-label="content2">Westworld</a></div>
  • The alt attribute isn't allowed in text links. The title is discouraged because some screen readers may read the title in addition to the link text. However, if you still want to make changes, you can extend a Core widget (and then you use the extended widget rather than the Core one). – WebElaine Dec 7 '18 at 19:28
  • There are many articles in the "Extend core widget" search. I think I can do the rest. I want to ask one more question to you. For example, when writing the name of the movie in the link article on the site, I would like to add "watch the movie" to the title attribute. I thought it would affect SEO well. Would you suggest? – İsmail Dec 7 '18 at 19:37
  • 1
    No, adding a title attribute no longer helps SEO - it actually harms it unless for some reason you need to add additional text for screen readers for context. Adding it purely "for SEO" is akin to keyword stuffing. – WebElaine Dec 7 '18 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.