WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Under the discussion tab on the post page, there's 'allow comments' and 'allow trackbacks and pingbacks', how would I hide the option to allow pingbacks from users but still have it be on by default?

share|improve this question
up vote 2 down vote accepted

Method 1 (CSS)

You can hide it for all non-admins via CSS:

function hide_ping_track_wpse_103502() {
    if( get_post_type() === "post" ){
        if( ! current_user_can( 'manage_options' ) ){
            // only for non-admins
            echo "<style>.meta-options label[for=ping_status], #ping_status{display:none !important;} </style>";
add_action( 'admin_head-post.php', 'hide_ping_track_wpse_103502' );





Method 2 (PHP)

You can also remove the native discussion metabox and replace it with your own:

add_action( 'admin_menu', 'remove_discussion_meta_box' );
add_action( 'add_meta_boxes', 'add_custom_discussion_meta_box' );

function remove_discussion_meta_box() {
    remove_meta_box('commentstatusdiv', 'post', 'normal');

function add_custom_discussion_meta_box() {
            __( 'Custom Discussion' ),

function custom_discussion_meta_box($post) {
<input name="advanced_view" type="hidden" value="1" />
<p class="meta-options">
        <label for="comment_status" class="selectit">
            <input name="comment_status" type="checkbox" id="comment_status" 
                   value="open" <?php checked($post->comment_status, 'open'); ?> /> 
            <?php _e( 'Allow comments.' ) ?>

         <input name="ping_status" type="hidden" id="ping_status" 
                    value="<?php echo $post->ping_status;?>" />

        <?php do_action('post_comment_status_meta_box-options', $post); ?>

where the ping_status form input field is hidden with the current value.



share|improve this answer
I'm not sure a CSS solution is the best way to go. – andy Jun 19 '13 at 15:16
You could of course remove the whole discussion metabox and add your own custom metabox with the modified content. – birgire Jun 19 '13 at 15:20
I updated the answer with that kind of solution. – birgire Jun 19 '13 at 17:11
Thanks, birgire. Which method do you think is better? – andy Jun 19 '13 at 17:25
good question, I might go with the second method, since the CSS I provided for the attribute target on the label might not be supported by all browsers ;-) – birgire Jun 19 '13 at 17:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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