简体   繁体   English

在wordpress中使用用户名创建变量链接

[英]Create a variable link with username in wordpress

I want to know how I can insert like this example link into a page in my WordPress: 我想知道如何将这样的示例链接插入到WordPress的页面中:

<a href="http://example.com/uploads/2017/03/(username).jpg">Mars Month Info</a>

when every user clicks on this link, see his/her info about that month. 当每个用户单击此链接时,请查看其有关该月的信息。 (username) will be a variable string that displays every user's username. (用户名)将是一个可变字符串,显示每个用户的用户名。

for example when "digi" user goes to that page, will see this link: 例如,当“ digi”用户转到该页面时,将看到以下链接:

<a href="http://example.com/uploads/2017/03/digi.jpg">Mars Month Info</a>

You can get the current logged in user's username with the function 您可以使用函数获取当前登录用户的用户名

wp_get_current_user();

This returns a user object that you can get out the username value, among other attributes. 这将返回一个用户对象,您可以获取用户名值以及其他属性。

$current_user->user_login

Source: https://codex.wordpress.org/Function_Reference/wp_get_current_user 资料来源: https : //codex.wordpress.org/Function_Reference/wp_get_current_user

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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