0

By default, the WP_List_Table has column names at the top and the bottom of the table.

How can I remove the bottom table headers? Thanks.

p.s. I have already subclassed the WP_List_Table.

1 Answer 1

1

You can override the WP_List_Table::display() method and remove the tfoot which contains the bottom table headers:

<tfoot>
<tr>
    <?php $this->print_column_headers( false ); ?>
</tr>
</tfoot>

Or you can add a specific class to the relevant admin page and use CSS to visually hide the bottom table headers:

.my-plugin-foo-page table.wp-list-table > tfoot {
    display: none;
}
5
  • 1
    Yes, I'm using display() override. it's not future-proof, though.
    – Raptor
    Oct 22, 2019 at 3:58
  • Yes, I agree. So if you are just concerned about the display, then the CSS approach would be a better option.
    – Sally CJ
    Oct 22, 2019 at 4:24
  • 1
    but this will raise another issue, Flash of Unstyled Content (FOUC), as CSS may be loaded slower than the layout display.
    – Raptor
    Oct 22, 2019 at 4:29
  • 1
    And I agreed, but I've no further comments regarding the FOUC.. however, if you want, you can suggest to the WP core about something like a filter which lets one decide whether the tfoot should be displayed or not.
    – Sally CJ
    Oct 22, 2019 at 4:42
  • 1
    thanks for your suggestion.
    – Raptor
    Oct 22, 2019 at 9: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.