我已将厨房创建为:[gallery columns="6" link="file" ids="156,113,99,67,103,102"]
现在,如何在中显示列表图像[gallery columns="6" link="file" ids="156,113,99,67,103,102"]
在中,索引为:
<a href="#" title=""><img src="link image in gallery">
.....
<a href="#" title=""><img src="link image in gallery">
有什么想法给我!
谢谢
最合适的回答,由SO网友:Heidel 整理而成
我想你应该用get_post_gallery_images
函数,这是下面文档中的示例
function pw_show_gallery_image_urls( $content ) {
global $post;
// Only do this on singular items
if( ! is_singular() )
return $content;
// Make sure the post has a gallery in it
if( ! has_shortcode( $post->post_content, \'gallery\' ) )
return $content;
// Retrieve the first gallery in the post
$gallery = get_post_gallery_images( $post );
$image_list = \'<ul>\';
// Loop through each image in each gallery
foreach( $gallery as $image_url ) {
$image_list .= \'<li>\' . \'<img src="\' . $image_url . \'">\' . \'</li>\';
}
$image_list .= \'</ul>\';
// Append our image list to the content of our post
$content .= $image_list;
return $content;
}
add_filter( \'the_content\', \'pw_show_gallery_image_urls\' );
https://codex.wordpress.org/Function_Reference/get_post_gallery_images