把这段代码添加到functions.php就可以实现相册gallery输出的自字义
add_filter( 'the_content', 'wpdocs_show_gallery_image_urls' );function wpdocs_show_gallery_image_urls( $content ) {global $post;if( ! is_singular() ) return $content;if( ! has_shortcode( $post->post_content, 'gallery' ) ) return $content;$gallery = get_post_gallery_images( $post );$image_list = '<ul>';foreach( $gallery as $image_url ) {$image_list .= '<li>' . '<img src="' . $image_url . '">' . '</li>';}$image_list .= '</ul>';$content .= $image_list;return $content;
}
原文链接 https://www.zhanyes.com/code/6052.html