我正在开发一个主题,在帖子内容之外有一个内置的图库。因此,我想做的是允许编辑器将图像附加到页面/帖子,而无需插入它们。
有点像特写图片,但有任意数量的图片。只是一个很好的上传UI,让主题来呈现它。
我查看了一些插件,尤其是NextGen Gallery,但到目前为止,它们都是通过在帖子正文中插入一个短代码来工作的。
我正在开发一个主题,在帖子内容之外有一个内置的图库。因此,我想做的是允许编辑器将图像附加到页面/帖子,而无需插入它们。
有点像特写图片,但有任意数量的图片。只是一个很好的上传UI,让主题来呈现它。
我查看了一些插件,尤其是NextGen Gallery,但到目前为止,它们都是通过在帖子正文中插入一个短代码来工作的。
您不必在将图像附加到此帖子后将其插入帖子。
编辑帖子时,单击“添加媒体”按钮。上载图像,上载后只需关闭“插入媒体”对话框(使用右上角的“x”按钮,而不是“插入帖子”按钮)。
然后,您可以使用以下代码获取(并显示)它们:
<?php
$images = new WP_Query(array(\'post_type\' => \'attachment\', \'post_mime_type\' =>\'image\', \'posts_per_page\' => -1));
while ($images->have_posts()) : $images->the_post();?>
<a href="<?php echo wp_get_attachment_url($post->ID); ?>">
<img width="100" height="100" src="<?php echo wp_get_attachment_thumb_url( $post->ID);?>" />
</a>
<?php endwhile; ?>
您也可以使用get_children
函数获取这些附件(请参见下文)。$attachments = get_children(array(
\'post_parent\' => $post->ID,
\'post_status\' => \'inherit\',
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'image\',
));
foreach ($attachments as $id=>$att ) { ... }
我在wordpress的帖子中上传了一些图片(例如,帖子#1和帖子#2)。现在我创建了一个新帖子(例如,帖子#3),在这篇帖子中我插入了WordPress 3.5图库,我没有在帖子#3中上传任何图像,而是使用了帖子#1和帖子#2中的图像。现在在帖子#3中,我想获得这些图片的链接,但我似乎无法获得。我正在使用以下代码:$attachments = get_children( array(\'post_parent\' => get_the_ID(), \'post_type\' => \'att
我正在开发一个主题,在帖子内容之外有一个内置的图库。因此,我想做的是允许编辑器将图像附加到页面/帖子,而无需插入它们。
有点像特写图片,但有任意数量的图片。只是一个很好的上传UI,让主题来呈现它。
我查看了一些插件,尤其是NextGen Gallery,但到目前为止,它们都是通过在帖子正文中插入一个短代码来工作的。
您不必在将图像附加到此帖子后将其插入帖子。
编辑帖子时,单击“添加媒体”按钮。上载图像,上载后只需关闭“插入媒体”对话框(使用右上角的“x”按钮,而不是“插入帖子”按钮)。
然后,您可以使用以下代码获取(并显示)它们:
<?php
$images = new WP_Query(array(\'post_type\' => \'attachment\', \'post_mime_type\' =>\'image\', \'posts_per_page\' => -1));
while ($images->have_posts()) : $images->the_post();?>
<a href="<?php echo wp_get_attachment_url($post->ID); ?>">
<img width="100" height="100" src="<?php echo wp_get_attachment_thumb_url( $post->ID);?>" />
</a>
<?php endwhile; ?>
您也可以使用get_children
函数获取这些附件(请参见下文)。$attachments = get_children(array(
\'post_parent\' => $post->ID,
\'post_status\' => \'inherit\',
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'image\',
));
foreach ($attachments as $id=>$att ) { ... }
我使用Wordpress for AngularJS作为后端(wp json插件),实际上我为主题制作的结构是这样的myApptheme -style.css //nothing special here just inits the theme -index.php -header.php -functions.php lib //here some overrides php --gallery.php app //h