Is it possible to change the title=""
attribute that Wordpress generates with the_author_posts_link()
?
It is currently displaying 'Messages of [User]' as a hover title but I wish to change this to something else.
Is it possible to change the title=""
attribute that Wordpress generates with the_author_posts_link()
?
It is currently displaying 'Messages of [User]' as a hover title but I wish to change this to something else.
Share Improve this question asked May 9, 2019 at 14:37 Kevin M.Kevin M. 638 bronze badges1 Answer
Reset to default 1Yes, it is, but you'll have to use get_author_posts_url()
(see Codex).
The example in the Codex is (not my code):
<a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>"><?php the_author(); ?></a>
You could add your own title="My Better Title"
in that <a>
tag to make it say whatever you like:
<a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>" title="My Better Title"><?php the_author(); ?></a>
Replace that with your text or anything you can generate. If you're getting text from somewhere else, be sure to wrap it in esc_attr()
so it doesn't break your HTML.