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.

Bulk delete media by year

We tried with couple of plugins , but there isn’t any with option to bulk delete images by month or year. If you have access to wp-cli you can try to delete attachments by year and month with: wp post delete $(wp post list –post_type=”attachment” -—year=2016 -—monthnum=12 –format=ids) or just by year with: wp post … Read more

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

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