Wrap a post image with a div if it doesn’t have a caption

You could try with if(is_admin()){ add_filter(‘image_send_to_editor’, ‘wrap_my_div’, 10, 8); function wrap_my_div($html, $id, $caption, $title, $align, $url, $size, $alt) { if( isset($caption) && $caption ) return $html; else return ‘<div class=”mydiv” id=”mydiv-‘.$id.'”>’.$html.'</div>’; } }

trouble with featured image

When you set that final argument of add_image_size() to false, it scales the image down until the height or width matches one of the set values, then it maintains the proportions. For example: A 600px by 400px image using your settings is 134px wide (the long dimension) and then 89px tall (proportional to 134px wide). … Read more

Editing featured image

You can add image sizes and cropping settings with the add_image_size() function. Call the declared name of your size at the frontend and you’ll have your desired size and crop. The image is stored as an id, you can pick whatever size you want with the the_post_thumbnail() function. PE: the_post_thumbnail(‘medium’); will show the featured image … Read more

How do I add a nested conditional within an echo – to use a default image if there isn’t one in the post?

try this $second_query = new WP_Query( $args ); if ( $second_query->have_posts() ): while( $second_query->have_posts() ) : $second_query->the_post(); $attachment_id = get_field(‘image’); $size = “customfeatins”; // (thumbnail, medium, large, full or custom size) $my_image = wp_get_attachment_image_src( $attachment_id, $size ); if (!my_image !== ”){ $image = $my_image[0]; } else { $image=”http://domain/image_source/your_image.jpg”; } endif; echo ‘<article> <img src=”‘ . … Read more