是否可以从帖子库中获取原始信息并显示在页面上,特别是针对滑块?
那么,您是否可以创建一个库,然后将库显示在带有全尺寸图像、图像标题和alt文本的页面上?
所以对于每个图像。。。
<div>
<img src=\'image source\' title=\'image title\' />
<figure>image caption, image alt tag</figure>
</div>
除了全尺寸图像、alt和字幕文本之外,基本上什么都去掉了?这可能吗?
谢谢你的帮助。
是否可以从帖子库中获取原始信息并显示在页面上,特别是针对滑块?
那么,您是否可以创建一个库,然后将库显示在带有全尺寸图像、图像标题和alt文本的页面上?
所以对于每个图像。。。
<div>
<img src=\'image source\' title=\'image title\' />
<figure>image caption, image alt tag</figure>
</div>
除了全尺寸图像、alt和字幕文本之外,基本上什么都去掉了?这可能吗?
谢谢你的帮助。
画廊本质上只是一组附加的帖子,所以。。。
$post_id = 1; // set to your desired parent post
$attachments = new WP_Query(
array(
\'post_parent\' => $post_id, // post to which the gallery is attached
\'post_status\' => \'inherit\',
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'image\',
// \'order\' => $order,
// \'orderby\' => $orderby
)
);
// var_dump($attachments); // debug
foreach ($attachments->posts as $p) {
var_dump($p);
var_dump(wp_get_attachment_image_src($p->ID));
var_dump(get_post_custom($p->ID));
}
您应该能够在转储的数据中找到所有需要的内容,以及更多内容。事实上,我认为您所需要的只是这些转储中的最后两个,因此您可以简化为:$post_id = 1; // set to your desired parent post
$attachments = new WP_Query(
array(
\'fields\' => \'ids\',
\'post_parent\' => $post_id, // post to which the gallery is attached
\'post_status\' => \'inherit\',
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'image\',
// \'order\' => $order,
// \'orderby\' => $orderby
)
);
// var_dump($attachments);
foreach ($attachments->posts as $ids) {
var_dump(wp_get_attachment_image_src($ids));
var_dump(get_post_custom($ids));
}
我正在使用默认的WordPress Gallery(以及Cleaner Gallery插件)来显示一些图像。画廊似乎没有的一件事是分页。我想做的是在6张图片之后添加上一个和下一个链接来浏览页面。话虽如此,有几个插件声称添加了此功能,但它们都是在没有新媒体库的情况下开发的,而新媒体库是WordPress 3.5的标准配置。我不想改变用户的体验。。。我只是想通过函数添加功能。php或循环本身。我可以将同样的东西应用到所有的库中,因此如果修复程序能够以某种方式找到库的短代码,那就太棒了!不知道该怎么做,只是在这