<?php
    $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' =>'image') );
    foreach ( $attachments as $attachment_id => $attachment ) {
            echo wp_get_attachment_image( $attachment_id, 'medium' );
    }
?>

 

$args = array(
    'post_type' => 'attachment',
    'post_status' => 'published',
    'posts_per_page' =>25,
    'post_parent' => 210, // Post-> ID;
    'numberposts' => null,
);

$attachments = get_posts($args);

$post_count = count ($attachments);

if ($attachments) {
    foreach ($attachments as $attachment) {
    echo "<div class=\"post photo col3\">";
        $url = get_attachment_link($attachment->ID);// extraigo la _posturl del attachmnet      
        $img = wp_get_attachment_url($attachment->ID);
        $title = get_the_title($attachment->post_parent);//extraigo titulo
        echo '<a href="'.$url.'"><img title="'.$title.'" src="'.get_bloginfo('template_url').'/timthumb.php?src='.$img.'&w=350&h=500&zc=3"></a>';
        echo "</div>";
    }   
}

 

 

$image_ids = get_posts(
    array(
        'post_type'      => 'attachment',
        'post_mime_type' => 'image',
        'post_status'    => 'inherit',
        'posts_per_page' => - 1,
        'fields'         => 'ids',
    ) );

$images = array_map( "wp_get_attachment_url", $image_ids );
echo json_encode($images);
// output
["https:\/\/meiji2.com\/wp-content\/uploads\/2017\/0926\/20170926225034-00045-3b177.jpg","https:\/\/meiji2.com\/wp-content\/uploads\/2017\/0926\/20170926225038-00046-cf396.jpg","https:\/\/meiji2.com\/wp-content\/uploads\/2017\/0926\/20170926225041-00047-a2060.jpg","https:\/\/meiji2.com\/wp-content\/uploads\/2017\/0926\/20170926225045-00048-bd5a7.jpg","https:\/\/meiji2.com\/wp-content\/uploads\/2017\/0926\/20170926225048-00049-ae685.jpg"]

$galleries = get_post_galleries_images( $postId );

发表评论

电子邮件地址不会被公开。