Created
February 7, 2021 21:39
-
-
Save diggeddy/9a04315d7cfc834e8efe87e1ce653df7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add skip-lazy class ( or any class ) to featured image of latest post | |
function skip_lazy_class_first_featured_image($attr) { | |
global $wp_query; | |
if ( !is_single() && 0 == $wp_query->current_post ) { | |
$attr['class'] .= ' skip-lazy'; | |
} | |
return $attr; | |
} | |
add_filter('wp_get_attachment_image_attributes', 'skip_lazy_class_first_featured_image' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment