Site logo

[Support request] Appending custom classes to existing ones in a body section

Home Forums Support [Support request] Appending custom classes to existing ones in a body section

Home Forums Support Appending custom classes to existing ones in a body section

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2299700
    Dalibor

    I’m sure filters are the way to do it, but I’m doing something wrong.

    add_filter( 'body.wp-show-posts-image', function( $classes ) {
        return array_merge( $classes, array( 'floating-image' ) );
    } );
    

    The goal is to append .floating-image class to the existing .wp-show-posts-image class (a part of the WP show post plugin from Tom) located in a body of a blog page.
    If it’s page specific, even better.

    Thanks in advance.

    #2299936
    David
    Staff
    Customer Support

    Hi there,

    when can i see the WP Show Posts list you want to change ?

    #2300593
    Dalibor

    <div class="wp-show-posts-image wpsp-image-center ">

    I’d like to add another class here.

    #2301035
    Ying
    Staff
    Customer Support

    <div class="wp-show-posts-image wpsp-image-center ">

    This doesn’t look like the body element, can you link us to where we can see the WPSP list?

    #2301067
    Dalibor

    Well, it is the body element.
    https://prnt.sc/H-3dT2C9QtTs

    I’ve appended the link to the page.

    #2301167
    Ying
    Staff
    Customer Support

    1. Your filter isn’t correct. You can’t change the filter name. For more info:
    https://docs.generatepress.com/article/add-a-custom-class-to-the-body-element/

    2. It’s not a body element, it’s just located inside the body element, like most elements on your site. So the filter won’t work.

    3. We have stopped supporting or updating WP show posts as the replacement of WP show posts has been released. I would recommend trying GenerateBlock’s Query loop block and image block so that you can add custom classes to the GB image block.

    #2301181
    Dalibor

    Thank you very much.

    #2301213
    Ying
    Staff
    Customer Support

    You are welcome 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.