Add bootstrap classes for WP tables

Bootstrap requires custom table classes. If a table is added to the_content this function with automatically add those classes. You can also add other classes i.e. table table-responsive.

/**
 * Snippet Name: Add bootstrap classes for WP tables
 * Snippet URL: https://www.wpcustoms.net/snippets/add-bootstrap-classes-wp-tables/
 */
  function wpc_add_custom_table_class( $content ) {
return str_replace( '', '
', $content ); } add_filter( 'the_content', 'wpc_add_custom_table_class' );
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x