Change attribute on the first post thumbnail in Categories
-
I try to change loading=”lazy” to loading=”eager” from the first post thumbnail in categories and tags. I tried to conditionally exclude posts and pages with !is_single() && !is_page() but the function doesn’t work.
add_filter( 'wp_get_attachment_image_attributes', function( $attrs ) { if ( !is_single() && !is_page() && is_front_page() && is_archive() && is_search() ) { global $wp_query; if ( $wp_query->current_post === 0 ) $attrs['loading'] = 'eager'; return $attrs; } return $attrs; } );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Change attribute on the first post thumbnail in Categories’ is closed to new replies.