Changing the the_author_posts_link() hover title

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.

Topic documentation customization Wordpress

Category Web


Yes, 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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.