I have to implement a default class for HTML-Tables at WordPress. The wp-standard is <table>
.. ist there any way to do this, that i get this output per default? <table class="abc xyz">
maybe with filters?
I have to implement a default class for HTML-Tables at WordPress. The wp-standard is <table>
.. ist there any way to do this, that i get this output per default? <table class="abc xyz">
maybe with filters?
Comments are closed.
In your case you need to add custom hook for
the_content
filter:Add this snippet to your
functions.php
file.I made a simple modification to get the code recognize other styles within the tag:
There is no table functionality in the default editors, visual or text, so unless are using an editor like
CKEditor
that does generate that markup, I’d use a shortcode.In your content, just write
[table]...[/table]
instead of<table>...</table>
I have to add that if your theme uses
body_class
andpost_class
correctly, and all you want to do is add a class to every<table>
in the post body, there is almost certainly existing markup in place that makes what you are doing unnecessary, whether you use a filter onthe_content
as @EugeneManuilov suggests or a shortcode.