admin管理员组文章数量:1323730
I have a shortcode that fetches some values, first_name
, last_name
and email
from a remote database. I'm trying to write a shortcode that will allow me to print 2 or more of those values within output between shortcode tags. For example, I may call my shortcode like this:
[user_data]{{firist_name}} {{last_name}}'s email address is {{email}}[/user_data]
or maybe
[user_data]The email address is {{email}} belongs to {{firist_name}} {{last_name}}.[/user_data]
I know I can write a shortcode that prints 1 of the individual values and call it 3 times like this:
[user_data field="first_name"] [user_data field="last_name"]'s email address is [user_data field="email"]
But that seems rather inefficient to me. Suppose i have the shortcode:
function user_data($atts, $content=null) {
$a = shortcode_atts( array(
'uid' => 0
), $atts );
// get an array with all of user's data
$fetched_data = my_data_fetching_function($a['uid']);
$out = $content;
return $out;
}
Is there any way to make $fetched_data
somehow available to $content?
本文标签: How to use multiple (or array) values in content of shortcode
版权声明:本文标题:How to use multiple (or array) values in $content of shortcode? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742121313a2421714.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论