The output of the settings API's function add_settings_field() is this:

 <th scope="row">Your title</th>
 <td> Your field output </td>

I know I can't change the way it's output, but I was wondering if there is a way I can put a display:none; on the <tr> with PHP? I don't want to do it with Javascript because then there is a flash of unstyled content.

Basically, I want a way to hide a row that's output via add_settings_field(), because I need it on the frontend - but later on in my flow.

  • Plenty of answers already but I don't think I understand. add_settings_field() doesn't return/output anything, so not sure what you are doing...
    – jimihenrik
    Jun 26, 2017 at 3:24

3 Answers 3


You can hide it using jQuery which will be inserted in the wp-admin header:

add_action( 'admin_head', 'wpse_239421_hide_section' );
function wpse_239421_hide_section() {
    <script type="text/javascript">
        jQuery(document).ready(function($) {
        } );

This will remove the closet tr bases on the scope=row.

  • I know I can use jQuery, but as clearly stated in my question, I don't want to use Javascript because there's a flash. Until the document is ready, I can see the HTML and then all of a sudden, it disappears.
    – PoeHaH
    Sep 16, 2016 at 5:13

The sixth parameter ($args) of the add_settings_field function can contain a class value that will be added to the <tr>.

You can use this with the built-in admin css class .hidden

    'Useless Field Label',
        'class' => 'hidden'
  • This would hide the input field, but not the entire tr including the field label.
    – EHerman
    Jan 20, 2019 at 14:33
  • Hi, thanks for your answer. Could you explain why do you think it will solve the problem? Dec 3, 2018 at 21:39
  • This only removes the first row.
    – welek
    Dec 10, 2018 at 7:59

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.