Title attribute processed
-
How can we ignore the title attributes? For some reason it’s hyphenated like crazy.
See: https://prnt.sc/f8iftm
Or view it live:https://www.magikweb.ca/blogue (Hover on the WWW picture)Thanks!
-
Hello @magikweb!
Please have a look at the first question in the FAQ. It should provide what you need to adapt your templates to use
the_title_attributeinstead ofthe_title. (It’s not about post titles in your case, but the underlying problem is the same.)-
This reply was modified 9 years ago by
pepe.
Thank you for the help. I checked and the right function is called (I’m using Theme X).
To fix the issue, I added the entry-thumb class in the “Ignore CSS classes” field and it fixed it.Thanks again!
That’s slightly weird, because if that
­is resulting from filteringthe_content, attribute nodes (like thetitleattribute of the<a>tag) should not be modified by the parser. What does the template generating that HTML code look like?I may have looked at the wrong template file since there are many, but all occurrences had the right function used as far as I could see.
This is where the issue was happening: https://www.magikweb.ca/blogueAnd this is the HTML code of that template (good luck to my markdown and no preview):
switch ( is_singular() ) { case true: printf( '<div class="entry-thumb">%s</div>', $thumb ); break; case false: printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>', esc_url( get_permalink() ), esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ), $thumb ); break; }If you’d like more details to validate and make sure it’s not a bug, I can help you out. Like I said, it might be my own error that I am not looking at the right place, but I hardly think I’d be in the wrong file since it’s the only one with the class “entry-thumb”.
Yeah, I’d like to check what’s going one there. Can you tell me more about the context of that template snippet? Is there some kind of output buffering or something? I still see the
­s in Chrome, BTW. Have you disabled your fix again?(BTW, why are the conditional hyphens in the title a problem? Entities should be perfectly harmless in an attribute.)
You’ve made me realize something important, it’s apparently not fixed! I tested it on Firefox on which it’s already OK, but on Chrome it doesn’t work, even with the CSS class ignored.
On Google Chrome it’s the same.
It’s visually an issue when optimizing our SEO, like “uti-li-ser” is the word “utiliser”.
I’ll have to look into it furthermore…
I don’t mind giving you access in private (email) if you’d like to check it out. It’s nothing big, but if the plugin can be improved, that’ll help us at the same time.
You should not see “uti-li-ser” on hover. As for SEO, Google is smart enough to know the meaning of
­(i.e. to ignore it). But still, from that template snippet, the soft hyphens should not be there at all. I don’t need access to your site, but it’s probably easier if we discuss this via mail. Just leave me a comment on https://code.mundschenk.at/wp-typography/ if you’d like to get in touch.@magikweb I’ve not gotten your contact info yet.
@magikweb: I’ve looked at the code again and I realized why it works the way it works:
the_title_attributedoes not circumvent all the filters hanging onthe_title, it just usesstrip_tagsto remove HTML tags afterwards.What
strip_tagsdoes not remove is the soft hyphens (­) added by hyphenation (which you can disable for post titles, by the way). If you want those gone, you would have to run the output ofthe_title_attributethroughstr_replaceto remove those added characters:$clean_title = str_replace( array( \PHP_Typography\Strings::uchr( 173 ), \PHP_Typography\Strings::uchr( 8203 ) ), '', the_title_attribute( 'echo=0' ) );(The example is for the upcoming version 4.2.0, to use with 4.1.x, you have to use
\PHP_Typography\uchrto access the same function. The snippet also removes any zero-width spaces that might be added by some of wp-Typography’s fixes.) -
This reply was modified 9 years ago by
The topic ‘Title attribute processed’ is closed to new replies.