So I've looked all through the documentation to see if I can find a filter hook of some sort to add an extra class name to the Wordpress/WooCommerce (CPT) post table in the backend. There must be a way somewhere, as WooCommerce adds on "status-wc-" into the html class.

Anyone able to help me out and point me in the right direction?

WooCommerce Custom Post Type


The function get_post_class() is used to generate these classes. You can filter post_class to change the output.


is_admin() && add_filter( 'post_class', function( $classes, $class, $post_id ) {
    $post = get_post( $post_id );

    // Decide whether to add a class or not …

    $classes[] = 'my-custom-class';

    return $classes;    
}, 10, 3 );
  • You sir, are a legend! You don't realise how long i was looking for that through the documentation. – James Simpson Dec 7 '16 at 10:36
  • @JamesSimpson Never rely on external documentation, just look at the source code. I have now added a link to that code to my answer. – fuxia Dec 7 '16 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.