• Resolved april

    (@aprilmaynard)


    I have no idea how to begin to figure this out, but get_attached_media and its variations are totally ineffectual with this theme.

    I use this snippet all the time, so I know it’s not that.

    Can you help me diagnose this, by chance?

    The site is still in development, so I can’t provide a URL.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author Silkalns

    (@silkalns)

    This theme doesn’t overwrite default WordPress functionality, so there must be some problems with your code.

    Here is an example how you can output all images attached to your post and link them to full size images. Feel free to use and modify this code to achieve what you were looking for.

    <?php
    $attachments = get_attached_media( 'image', $post->ID );
    
    foreach($attachments as $attachment) {
        $img_full = wp_get_attachment_url($attachment->ID);
        $img = wp_get_attachment_image_src($attachment->ID, 'full');
        //Now you can output any HTML you want to make it work
        if($img !== false) {
    ?>
    <a href="<?php echo $img_full; ?>" title="<?php echo $attachment->post_title; ?>" target="_blank"><img src="<?php echo $img[0]; ?>" /></a>
    <?php
        }
    }
    ?>

    Thread Starter april

    (@aprilmaynard)

    Okay, I don’t get it – why did this work, but nothing else??

    Thank you for doing this for me. The only issue now is getting it to output into a lightbox!

    I appreciate it – thank you ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Why is get_attached_media not working with this theme?’ is closed to new replies.