Displaying all images from a WordPress post

前端 未结 5 1533
一整个雨季
一整个雨季 2020-12-09 23:36

I have this piece of code I found on some blog, that\'s supposed to display all images from a WordPress post.

function getImage() {
    global $more;
    $m         


        
5条回答
  •  遥遥无期
    2020-12-10 00:24

     'attachment',
            'numberposts' => -1,
            'post_parent' => $post->ID
            );
    
        $attachments = get_posts( $args );
    
        if ( $attachments )
        {
            foreach ( $attachments as $attachment )
            {
    
            echo wp_get_attachment_image( $attachment->ID, false );
    
            }
        }
    
        endwhile;
    ?>
    

    Source : http://960development.com/code-snippet/get-all-the-images-attached-with-a-wordpress-post/

提交回复
热议问题