Displaying an image’s alt title and caption inside a fancybox window. Working, but showing the same alt and caption for each image

Your problem is with your foreach loops… here: if ($images) { foreach($images as $image) { $caption = $image->post_excerpt; } } and here: //alt title foreach ($images as $attachment_id => $image) { $img_alt = get_post_meta($attachment_id, ‘_wp_attachment_image_alt’, true); } Basically what is happening is that your $caption and $img_alt variables are being set at each iteration of … Read more

Get attachments only for this post

Try this using the get_children function: global $post; $args = array( ‘numberposts’ => -1, ‘order’=> ‘ASC’, ‘post_mime_type’ => ‘image’, ‘post_parent’ => $post->ID, ‘post_status’ => ‘any’, ‘post_type’ => ‘attachment’ ); $attachments = get_children($args); Reference: http://codex.wordpress.org/Function_Reference/get_children

Echo Permalink in Attachment outside of loop?

Jez, unpatient Jez 🙂 <?php $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => $post->ID ); $attachments = get_posts( $args ); if ( $attachments ) { foreach ( $attachments as $attachment ) { echo ‘<li> <a href=”‘. get_permalink($attachment->ID) .'” title=”Permanent Link to<?php the_title_attribute(); ?>”>’; echo wp_get_attachment_image( $attachment->ID, ‘full’ ); echo … Read more

Post Gallery list attachments except the one used as post thumbnail

You can use the exclude parameter. global $post; $args = array( ‘exclude’ => get_post_thumbnail_id( $post->ID ) ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘numberposts’ => -1, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘post_parent’ => $post->ID ); $images = get_posts($args); http://codex.wordpress.org/Template_Tags/get_posts http://codex.wordpress.org/Function_Reference/get_post_thumbnail_id

How to hide image-url if no attachment?

Assuming you’re following this tutorial: http://wp.tutsplus.com/tutorials/automagic-post-thumbnails-image-management/ Replace the echo statement at the end of get_attachment_picture with a return, then change your image code. Here is your new image code: // get the URL of the image $src = get_attachment_picture(); // if the url is not empty, display the image if(!empty($src)){ ?> <img src=”https://wordpress.stackexchange.com/questions/48896/<?php echo $src; … Read more

Correct attachment size

You need to echo your wp_get_attachment_image, BUT since this function returns a HTML object in the form of, <img src=”https://wordpress.stackexchange.com/questions/67508/path/to/image.jpg”/> It’s not going to work because you are are trying to return this function withing the href attribute of an anchor <a> This is wrong, <a href=”https://wordpress.stackexchange.com/questions/67508/<?= wp_get_attachment_image( $attachment->ID,”blog-thumb’); ?>”></a> This is right, <a href=”https://wordpress.stackexchange.com/questions/67508/<?php … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)