add img class to native wordpress galleries

try this.Passed $attachment->ID to get_post_meta to retrive alt tag of each image add_filter(‘wp_get_attachment_link’, ‘galleryWIthClass’); function galleryWithClass($src) { $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => null, ‘post_status’ => null, ‘post_parent’ => get_the_ID() ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { $alt = get_post_meta($attachment->ID, ‘_wp_attachment_image_alt’, true); $html= str_replace(‘<img’, ‘<img class=”‘. $alt.'” ‘, … Read more

Display gallery on bottom after content

This is not bulletproof, but should work perfectly fine in most cases: class WPSE_105676_Gallery_First { private static $_gallery = ”, $_handler; public static function gallery( $attr ) { self::$_gallery .= is_callable( self::$_handler ) ? call_user_func( self::$_handler, $attr ) : ”; return ”; } public static function content( $text ) { $text .= self::$_gallery; self::$_gallery = … Read more

Removing featured image from gallery?

Assuming that you are using the standard functionality of the gallery: You can extract the id of the images without having to do a query for attachments of that post with: preg_match(‘/\/’, get_the_content(), $ids); Then make an array of these values: $ids = explode( ‘,’ $ids[1] ); Eventually check if the id of the featured … Read more

Add Lightbox To WordPress Native Gallery

By default there is a difference in the HTML output for images inserted alone or via . A direct image link will output an <a href=””> to an actual image mime type, like: <a href=”https://wordpress.stackexchange.com/questions/119659/some-image.jpg”> An attachment <a href=””> outputs an attachment URI like: <a href=”https://wordpress.stackexchange.com/questions/119659/some-link?attachment_id=126″ or ../attachment/2013/ As for a filter I don’t think … Read more

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