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
    Commented Jun 26, 2017 at 3:24

4 Answers 4


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
    Commented 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
    Commented Jan 20, 2019 at 14:33
  • Hi, thanks for your answer. Could you explain why do you think it will solve the problem? Commented Dec 3, 2018 at 21:39
  • This only removes the first row.
    – welek
    Commented Dec 10, 2018 at 7:59
    'This is the setting title',
     array('class' => 'hidden')

That should/must do the job. Just add the extra arguments "class" used when outputting the field.

  • 1
    Hi - if you want to take ownership of this with your new account, see the merging accounts help. Editing it won't do that.
    – Rup
    Commented Aug 15, 2022 at 16:02
  • 1
    Your answer looks identical to already given.
    – nmr
    Commented Aug 16, 2022 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.