0
votes

Both of the following pages use the Archive template

Yet they display content differently as on the first example, the classes "woocommerce woocommerce-page" are added to the < body> tag

How do I tell Wordpress to add the two classes "woocommerce" and "woocommerce-page" to all archive pages?

1

1 Answers

2
votes

Your theme header should have something like <body <?php body_class(); ?>>.

You can add to your functions.php, or, preferably, in a custom plugin the following filter to manipulate the classes being output:

add_filter( 'body_class', 'b5f_modify_body_classes', 10, 2 );

function b5f_modify_body_classes( $classes, $class )
{
    // Modify the array $classes to your needs
    if( is_archive() )
    {
        $classes[] = 'woocommerce';
        $classes[] = 'woocommerce-page';
    }    
    return $classes;
}

You can check WordPress function get_body_class() to see how it can be built.