• carltonbale

    (@carltonbale)


    I’m wanting to modify the title tag attribute of links to pages and posts within WordPress. By default, the title attribute is set to be the same as the post title; when the mouse is hovered over a post named “My latest post”, the tooltip shows the text “My latest post”.

    I would like to modify the contents of the title attribute to include an excerpt of the post rather than the title. So, when the mouse is hovered over a post, the tooltip will instead show the excerpt text for the post (rather than the post title.) This is mostly intended to make lists of recent posts more usable (and similar to the functionality of sites such as originalsignal.com and popurls.com.)

    I plan to use javascript to format the tooltip to handle the additional text. That part is pretty straight forward. What I can’t figure out is how to modify the title attribute for links to automatically include non-default text (this is what feeds the javascript.) The resulting HTML output might look something like this:

    <a href="https://domain.com/my-new-post/" TITLE="Excerpt from my new post here">My New Post</a>

    Or maybe it could be contained in a <span title=""></span> wrapping around the post title.

    I’m looking for any ideas on how to do this. Thanks in advance.

Viewing 1 replies (of 1 total)
  • Thread Starter carltonbale

    (@carltonbale)

    I’ve searched through some WordPress code but have been unable to find anything. Any suggestions on how I might approach this?

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Title Attribute for Post Links (include excerpt instead of post title)’ is closed to new replies.