【发布时间】:2015-09-19 12:41:57
【问题描述】:
允许用户从前端上传和访问媒体文件。我正在使用以下代码检索媒体文件并在用户前端显示。我的 wordpress 上传中有 40 个媒体文件,但我想展示例如单页有 20 个媒体文件,我想知道是否有人可以帮助编写媒体文件的上一页和下一页导航代码。例如第 1 页 2 3 ... 10
<?php
$args = array(
'post_type' => 'attachment',
/* 'posts_per_page' => '2', */
'numberposts' => -1,
'post_status' => null,
'author' => $current_user->ID,
'post_parent' => $post->ID,
'caller_get_posts'=> 1,
);
$attachments = get_posts( $args );
if ($attachments) {
foreach ($attachments as $attachment) {
echo '<tr><td><a href="'.wp_get_attachment_url($attachment->ID).'" rel="shadowbox" title="'.$attachment->post_excerpt.'">';
echo ($attachment->_wp_attached_file);
echo '</a>
</td>
</tr>';
}
?>
【问题讨论】: