wordpress相册gallery自定义

把这段代码添加到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 = '
    '; foreach( $gallery as $image_url ) { $image_list .= '
  • ' . '' . '
  • '; } $image_list .= '
'; $content .= $image_list; return $content; }

原文链接 https://www.zhanyes.com/code/6052.html

相关文章

你可能感兴趣的:(wordpress,前端,javascript,开发语言,wordpress)