Wordpress jQuery帖子附件图片库?

时间:2010-09-23 05:29:17

标签: wordpress

如果你们中的任何一个人对以下情况有一个很好的解决方案,那就很好奇......因为我自己从来没有想过任何事情,而且通常不得不诉诸“post-image-1”之类的自定义字段,通过“post-image- 10“并手动粘贴jpg的文件名。这是一个可怕的解决方案,只适用于技术精湛的海报。

基本上我希望非技术精明的用户能够将多个图像上传/附加(但不插入实际的帖子内容)到帖子,这将变成一个临时的画廊。

然后我希望使用基本的jQuery灯箱库功能在帖子后面的列表中的列表中输出这些附件。

它不必通过附件,它可以是一个独立的插件,只要它提供可自定义的标记。基本上任何可以实现相同目标的解决方案都是不可思议的。

以前有人这样做过吗?我错过了一些非常明显的东西吗?我甚至都不知道究竟是什么叫这个,所以到目前为止我对谷歌的研究还没有太多运气:(

谢谢!

1 个答案:

答案 0 :(得分:1)

您可以将图片上传到附件中,但实际上不能将它们插入帖子中,然后有一些功能可以调用这些文件。

你可以在这里查看文档 http://codex.wordpress.org/Function_Reference/get_children

这是一个例子

            <div id="slideshow">
            <?php
                $attachments = get_children( array(
                        'post_parent'    => get_the_ID(),
                        'post_type'      => 'attachment',
                        'numberposts'    => 10, // show all -1
                        'post_status'    => 'inherit',
                        'post_mime_type' => 'image',
                        'order'          => 'ASC',
                        'orderby'        => 'menu_order ASC'
                    ));
                unset( $attachments[ get_post_thumbnail_id($p_id) ] );
                foreach ( $attachments as $attachment_id => $attachment ) {
             ?>
                    <img src="<?php echo wp_get_attachment_url($attachment_id);?>" alt="Chevrolet" width="540" height="246" />
            <?php
                }
            ?>