Count images in post then add class if just one

Using @pascalvgemert’s suggestion as a starting point, I’m using the following script: jQuery(document).ready(function() { var imgCount = jQuery(“.single-post #content-left p a”).children(“img”).length; if (imgCount == 1) { jQuery(“img”).addClass(“lone-image”); } }); Works like a charm.

How can we see which posts don’t have a featured image or it doesn’t exist anymore?

In form of a shortcode: add_shortcode(‘nofeatures’, ‘wpse_51768_shortcode’); function wpse_51768_shortcode() { $posts = get_posts( array(‘numberposts’ => -1) ); foreach ( $posts as $post ) { $featured = get_the_post_thumbnail( $post->ID, ‘thumbnail’, null ); if ( $featured ) echo ‘Has Featured Image: ‘ . $post->post_title . ‘<br />’; } } [update] The following outputs the posts that don’t … Read more

Open attachments in new tab/window

Presuming you don’t have a blank install have you tried disabling all your active plugins to see if it might be a conflict? If you can set the links to open in a new window when no plugins are active then activate one plugin at a time to figure out the culprit. Also check if … Read more