最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

customization - Changing the the_author_posts_link() hover title

programmeradmin1浏览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.

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 badges
Add a comment  | 

1 Answer 1

Reset to default 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.

发布评论

评论列表(0)

  1. 暂无评论