简体   繁体   中英

Link author name to author profile page in wordpress

I've author profile set up separately, and I'm printing author name outside of loop using strlen to limit the long names but unable to get the link attached to author name.. It just prints the author name without link in it.. Your help will be highly appreciated..

I tried with this one, which simply output the author name without link..

echo strlen(get_the_author_link()) > 13 ? substr(get_the_author_link(),0,12).'..' : get_the_author_link(); 

The documentation for get_the_author_link ( https://codex.wordpress.org/Function_Reference/get_the_author_link ), says that the function returns the link to the authors website. This link is an html link. It has a text and a href attribute.

The text of this link is the name of the author. The href attribute of this link is the link to the author's website. The substr function that you are using extracts the first 12 characters of this link so it will return a portion of the link's html.

If you want to shorten the author's name then you can shorten the text of the link. Another option is to display the authors link with a small font using css

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM