How to specify a class added to my gallery

Here are three methods Approach #1 It’s common to wrap the output with custom HTML. We can do that by using the post_gallery filter and the gallery_shortcode() callback: /** * HTML Wrapper – Support for a custom class attribute in the native gallery shortcode */ add_filter( ‘post_gallery’, function( $html, $attr, $instance ) { if( isset( … Read more

How to mark every 3rd post

My approach. No extra function, no filter. 🙂 <?php $GLOBALS[‘wpdb’]->current_post = 0; ?> <div <?php post_class( 0 === ++$GLOBALS[‘wpdb’]->current_post % 3 ? ‘third’ : ” ); ?>> Alternative: <div <?php post_class( 0 === ++$GLOBALS[‘wpdb’]->wpse_post_counter % 3 ? ‘third’ : ” ); ?>>