79209961

Date: 2024-11-21 06:45:54
Score: 0.5
Natty:
Report link

I came up with this to better demonstrate what I intended to do. The example below works but however it obviously 'replaces' the class, where I need it to add the additional class.

In index.php

echo '<main class="' . apply_filters( 'jm_content_area_wrap', 'content' ) . '" role="main">';

Then say in a page template I can use this

// Add .bg-primary class
function jm_test_class( $test_class ) {

    $test_class = 'content bg-primary'; // This replaces the .original class, rather than adding to it, so I need to add .content back.
    return $test_class;

}
add_filter( 'jm_content_area_wrap', 'jm_test_class' );
Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: James Mitchell