如何限制用户在WordPress中只能访问他们自己的媒体文件 时间:2016-10-16 作者:Hridoy Khan Joy <?php $attachments = get_children( array(\'post_parent\' => get_the_ID(), \'post_type\' => \'attachment\', \'post_mime_type\' =>\'image\') ); foreach ( $attachments as $attachment_id => $attachment ) { echo wp_get_attachment_image( $attachment_id, \'medium\' ); }?>您好,我使用此代码在自定义模板中显示媒体附件如何限制用户只能从此代码访问自己的媒体文件 1 个回复 SO网友:Ishan Sharma 您可以添加author 要在中进行阵列的参数get_children.代码的第2行如下所示:<?php $attachments = get_children( array(\'post_parent\' => get_the_ID(), \'post_type\' => \'attachment\', \'post_mime_type\' =>\'image\', \'author\' => get_current_user_id() ) ); 文章导航