Custom Gallery HTML only working when images are attached to post/page

You’re not passing your attribute array to the shortcode_atts method. You’re passing in an uninitialized variable. Your function starts with function get_my_gallery_content ( $atts ) { But then you don’t reference $atts again. The code is reading $attr, which is empty. Change the line ), $attr, ‘gallery’)); to ), $atts, ‘gallery’)); You also need to … Read more

Display attachment resolution size

The wp_get_attachment_img_src( $attachment_id ) function returns an array consisting of: The URL to the img width height To get the actual attachment/thumbnail/featured image ID, you want to use $att_ID = get_post_thumbnail_id( get_the_ID() ); in the loop. Outside the loop, you would have to get the Post ID somehow to feed it in as get_the_ID() refers … Read more

delete image attachments of a custom post type except featured image

Try this on for size: add_action(‘save_post’, function($post_id, $post, $update){ if ( $post->post_type === ‘newcomer’ && $post->post_status === ‘publish’ ) { $attachments = get_attached_media( ‘image’, $post->ID ); $featured_id = get_post_thumbnail_id(); //unset the featured image by ID if it exists unset($attachments[$featured_id]); foreach ( $attachments as $attachment ) { wp_delete_attachment( $attachment->ID, false ); } } }, 10, 3); … Read more

wp_mail not sending attachment

You said in your OP that the absolute path was returned, but you are using the ‘baseurl’ value which gives you a URL to the file that you can browse to. That’s a URL, which is not the same as the path to the file in the file system. This line is your issue: $attachment … Read more

How to specify width and height in the_content for image attachments

I believe this is what your looking for. The complete code can be found in twentyten’s loop-attachment.php template. Look for the <p class=”attachment”> tag. There are two filters there. One for width and the other for height (currently set to 900px for both). <?php if ( wp_attachment_is_image() ) : $attachments = array_values( get_children( array( ‘post_parent’ … Read more

custom admin thumbnail for videos, not getting post’s id?

First, you don’t need the apply_filters below. That is called directly from the wp_mime_type_icon() function already. The issue is that your add_filter() call is missing the $accepted_args parameter. The add_filter() function has the following construct: add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) So the $accepted_args is 1 by default. Because of this, only the … Read more

How do i add LIGHTBOX to Attachments?

i think most lightbox plugins require the rel or class attribute to be on the link, so: <a href=”https://wordpress.stackexchange.com/questions/43630/<?php echo wp_get_attachment_url($post->ID); ?>” rel=”lightbox” title=”<?php echo wp_specialchars( get_the_title($post->ID), 1 ) ?>”><?php echo wp_get_attachment_image($post->ID, ‘large’ ); ?></a>

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