我正在尝试获取并在wordpress中为用户显示特定的元数据项。我要获取的数据值是事件日期的值。我尝试了以下代码,但没有运气
<?php
$user_ID = get_current_user_id();
$key = 'Event Date';
$single = true;
$user_last = get_user_meta( $user_id, $key, $single );
echo '<p>The '. $key . ' value for user id ' . $user_id . ' is: ' . $user_last . '</p>';
?>
Run Code Online (Sandbox Code Playgroud)
其中“事件日期”是Ive添加到用户配置文件的自定义元字段。
请帮忙
好的,我设法弄清楚了,它可以与以下代码一起使用:
<?php
$user_id = get_current_user_id();
$key = 'Event Date';
$single = true;
$user_last = get_user_meta( $user_id, $key, $single );
echo $user_last;
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9609 次 |
| 最近记录: |