0

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.

1

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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.