Exclude featured image from gallery code stops Lightbox from working

I solved this by using this code function exclude_thumbnail_from_gallery($null, $attr) { if (!$thumbnail_ID = get_post_thumbnail_id()) return $null; // no point carrying on if no thumbnail ID // temporarily remove the filter, otherwise endless loop! remove_filter(‘post_gallery’, ‘exclude_thumbnail_from_gallery’); // pop in our excluded thumbnail if (!isset($attr[‘exclude’]) || empty($attr[‘exclude’])) $attr[‘exclude’] = array($thumbnail_ID); elseif (is_array($attr[‘exclude’])) $attr[‘exclude’][] = $thumbnail_ID; // … Read more

Single post layout based on featured image size

The problem there is that the WP uploader will automatically resize any image you upload to all your specified image sizes, providing the original is larger than the specified size. Relying on uploading an image between two specific sizes is a very flimsy mechanism for dictating layout. What is actually different about the content of … Read more

Archive show thumbnail

You can check if the post as a thumbnail and if not the get the first image in the post ex: <?php $size=”thumbnail”; if ( has_post_thumbnail() ) { ?> <a href=”https://wordpress.stackexchange.com/questions/58503/<?php the_permalink(); ?>” title=”<?php the_title_attribute(); ?>” > <?php the_post_thumbnail($size, array(‘class’ => ‘alignleft’)); ?> <?php } else { $attachments = get_children( array( ‘post_parent’ => get_the_ID(), ‘post_status’ … Read more

Retrieve post thumbnail as array

The solution is to use wp_get_attachment_image_src. As per the Codex: $attachment_id = 8; $size=”full”; // returns an array $image_attributes = wp_get_attachment_image_src( $attachment_id, $size ); Although the return is said to be: [0] => url [1] => width [2] => height There is a fourth element that indicates if it is the full image (false) or … Read more

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