Site logo

Archived topic

customizing blog page content

3 replies · Started by eric on October 3, 2019

Viewing posts 1–4 of 4

Hi there,

I would like to customize the entries that appear on the blog page. Specifically, I would like to apply a new class to the images that display as the featured image. Please let me know if this is possible.

Below is an excerpt from my current blog post where I have added NEW_CLASS__IS_HERE to the code.

Thanks in advance for your help.



Hi there,

Try this PHP snippet:

add_filter( 'generate_featured_image_output', function( $output ) {
    return sprintf( // WPCS: XSS ok.
        '<div class="post-image CUSTOM-CLASS">
					<a href="%1$s">
						%2$s
					</a>
				</div>',
				esc_url( get_permalink() ),
				get_the_post_thumbnail(
					get_the_ID(),
					apply_filters( 'generate_page_header_default_size', 'full' ),
					array(
						'itemprop' => 'image',
             )
         )
    );
} );

Adding PHP: https://docs.generatepress.com/article/adding-php/

Let me know if this helps :)

Wonderful! That works beautifully. Thanks very much for your help!

No problem :)

This archived topic is closed to new replies.