我想获得上传媒体文件的用户的昵称。我正在获取包含此代码的所有媒体文件,并希望链接到用户昵称/个人资料
<?php
$args = array(
\'post_type\' => \'attachment\',
\'post_status\' => null,
\'post_parent\' => null, // any parent
\'numberposts\' => -1,
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $post) {
?>
<?php $author = get_the_author($post->ID); ?>
<a href="myurl/<?php echo $author ?>"><img src="<?php echo wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?>" width="400" alt="<?php the_title(); ?>"/></a>
<?php
}
}
?>
固定的
<?php
$args = array(
\'post_type\' => \'attachment\',
\'post_status\' => null,
\'post_parent\' => null, // any parent
\'numberposts\' => -1,
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $post) {
?>
$temp_post = get_post($post_id);
$user_id = $temp_post->post_author;
$user_login = get_the_author_meta(\'user_login\',$user_id);
<a href="myurl/<?php echo $user_login ?>"><img src="<?php echo wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?>" width="400" alt="<?php the_title(); ?>"/></a>
<?php
}
}
?>
我不想让它起作用。我尝试了很多组合,但昵称没有呈现出来。有人能帮我吗?谢谢