Ready to get started?Download WordPress


[resolved] Attachment galore (2 posts)

  1. Edde Beket
    Posted 1 year ago #

    Hi all,

    I'm trying to create a list of images, using my own "sizes". Something like
    wp_get_attachment_link ( $attachment->ID, 'header' );
    comes close, but it returns the header-image and link to the large (original) image. I don't need the link, I want the URI - and that of it's smaller brother ('navthumb').

    The following is als very close, but only returns the results of ONE attachment and not all.

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post();
            $args = array(
              'post_type' => 'attachment',
              'numberposts' => -1,
              'post_status' => null,
              'post_parent' => $post->ID
            $attachments = get_posts( $args );
              if ( $attachments ) {
                foreach ( $attachments as $attachment ) {
         $header_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'header');
         $thumb_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'navthumb');
     echo $header_image_url[0];
     echo $thumb_image_url[0];
            endwhile; endif; ?>


  2. Edde Beket
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic