I want to use the Twitter follow button for site authors on all posts.
我想在所有帖子上使用Twitter关注按钮进行网站作者。
The Twitter structure is here:
Twitter结构在这里:
<a href="https://twitter.com/twitterapi" class="twitter-follow-button" data-show-count="false" data-lang="en">Follow @twitterapi</a>
Yes, it works but this place must be generic. I should import Wordpress $user->ID
in this structure. How can I do this?
是的,它有效,但这个地方必须是通用的。我应该在这个结构中导入Wordpress $ user-> ID。我怎样才能做到这一点?
2 个解决方案
#1
1
You can use get_current_user_id()
in wordpress.
您可以在wordpress中使用get_current_user_id()。
To get the author of the current post try the following
要获取当前帖子的作者,请尝试以下操作
<a href="https://twitter.com/<?php esc_attr_e(get_the_author()) ?>"
class="twitter-follow-button"
data-show-count="false" data-lang="en">Follow @<?php echo get_the_author() ?></a>
#2
0
To get the ID of the current user logged you can simple user this wordpress function:
要获取当前用户的ID,您可以简单地使用此wordpress功能:
get_current_user_id()
To put it in whatever html code you should just open the tags where you need a dynamic value.
要将它放在任何HTML代码中,您只需打开需要动态值的标签。
<a href="https://twitter.com/twitterapi" class="twitter-follow-button" data-show-count="false" data-lang="en">Follow <?php get_current_user_id() ?></a>
or using shortcut tags:
或使用快捷标签:
<a href="https://twitter.com/twitterapi" class="twitter-follow-button" data-show-count="false" data-lang="en">Follow <?=get_current_user_id()?></a>
#1
1
You can use get_current_user_id()
in wordpress.
您可以在wordpress中使用get_current_user_id()。
To get the author of the current post try the following
要获取当前帖子的作者,请尝试以下操作
<a href="https://twitter.com/<?php esc_attr_e(get_the_author()) ?>"
class="twitter-follow-button"
data-show-count="false" data-lang="en">Follow @<?php echo get_the_author() ?></a>
#2
0
To get the ID of the current user logged you can simple user this wordpress function:
要获取当前用户的ID,您可以简单地使用此wordpress功能:
get_current_user_id()
To put it in whatever html code you should just open the tags where you need a dynamic value.
要将它放在任何HTML代码中,您只需打开需要动态值的标签。
<a href="https://twitter.com/twitterapi" class="twitter-follow-button" data-show-count="false" data-lang="en">Follow <?php get_current_user_id() ?></a>
or using shortcut tags:
或使用快捷标签:
<a href="https://twitter.com/twitterapi" class="twitter-follow-button" data-show-count="false" data-lang="en">Follow <?=get_current_user_id()?></a>