[Resolved] customizing blog page content

Home Forums Support customizing blog page content

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1025382
    eric

    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.



    #1025474
    Leo
    Staff
    Customer Support

    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 🙂

    #1027218
    eric

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

    #1027292
    Leo
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.