[Resolved] Add a custom class to the post

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Add a custom class to the post

This topic contains 5 replies, has 2 voices, and was last updated by  Tom 4 months, 1 week ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10114

    Ben
    Participant

    Hi Guys,

    I’m trying to use MixItUp to enable js-based filtering of posts. I need to add the class of ‘mix’ to the posts displayed by WPSP to get it working, is there a filter available to do this?

    Thanks,
    Ben

    #10125

    Tom
    Keymaster

    Hi Ben,

    WPSP uses the standard post_class() function add classes to posts, so you can do this:

    add_filter( 'post_class', function( $classes ) {
        $classes[] = 'mix';
    
        return $classes;
    } );

    Let me know if you need more info 🙂

    #10129

    Ben
    Participant

    Thanks Tom, that’s perfect & so simple.

    On a side note, i’m trying to write some functions using custom post types & custom terms and struggling – do you recommend any WP forums I could ask questions?

    #10134

    Tom
    Keymaster

    If they’re coding questions, this site should be super helpful: https://wordpress.stackexchange.com/

    #10135

    Ben
    Participant

    thanks Tom, will do

    #10147

    Tom
    Keymaster

    No problem! 🙂

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.