martedì 11 dicembre 2012

Immagini su wordpress

1) Per prendere tutte le immagini che sono nella gallery di riferimento al post.     

<?php
                     // print_r($post);
                     //$aaa= catch_that_image();
               
                    $x=0;
                    $args = array(
                    'orderby' => 'menu_order',
                    'post_type' => 'attachment',
                    'post_parent'    => get_the_ID(),
                    'post_mime_type' => 'image',
                    'post_status'    => null,
                    'numberposts'    => -1,
                    );
                    $attachments = get_posts($args);
                    ?>
                   
                    <?php // if ($attachments) : ?>
                   
                    <?php foreach ($attachments as $attachment) : ?>
                           
                    <?php
                    $src = wp_get_attachment_image_src( $attachment->ID, 'large');
                    if(is_singular())
                     $src = wp_get_attachment_image_src( $attachment->ID, 'single-thumb');

endforeach;

                    ?>

Nessun commento: