I'm trying to disable all functionality related to pingbacks/trackbacks in WordPress and so far I have this:

add_action( 'pre_ping', 'disable_pingback' );

function disable_pingback( &$links ) {
    foreach ( $links as $l => $link ) {
        if ( 0 === strpos( $link, get_option( 'home' ) ) ) {
            unset( $links[ $l ] );

However when I open up the page options and enable discussion, I still see this:

enter image description here

I found this answer (method 2), but it is over 5 years old now and I wasn't sure if totally replacing the whole section was the best way to do things compatibility wise, so I am asking again...

Is there a cleaner way to accomplish this?

  • Disable the xmlrpc.php if you're not using it anymore. The pingback/trackback will disable too. You can block xmlrpc via Nginx or .htaccess config. Commented Jul 29, 2018 at 5:10
  • @HồTrọngLinhÂn I thought of doing that but I read that can block access to things such as WP apps that legitimately need to connect to it remotely.
    – Brett
    Commented Jul 29, 2018 at 7:52
  • Second method is the best way to do it.
    – kierzniak
    Commented Aug 6, 2018 at 9:01

5 Answers 5


The WordPress Codex solutions weren't working for me regardless of what parameters I used or the priorities set, probably because my setup is pretty complex or as others have commented. The first chunk of code may work for you but I don't have a default environment at the moment to test. The second chunk of code definitely worked for me. The last chunk of code removes the option from the post's quick edit as well.

You will still need to disable the functionality as you have done.

Wordpress Codex solution, (hooks into add_meta_boxes so it fires last, but you can use admin_menu or do_meta_boxes instead). Documentation Here

function remove_trackbacks_pingbacks() {

            remove_meta_box('trackbacksdiv', 'post', 'normal');

add_action('add_meta_boxes', 'remove_trackbacks_pingbacks');

This may be overkill, but this is what actually worked for me. Note that it will remove the option in the box from displaying everywhere, including pages too. It also allows you to customize the HTML as well just in case you wanted to add a note to tell the user that Pingbacks and Trackbacks have been disabled. (this may or may not suit your needs, but here it is anyway). Documentation Here

    function remove_trackbacks_pingbacks ($post_type, $post) {

    global $wp_meta_boxes, $current_screen;

    # Remove "ping_status" from `commentstatusdiv`:
    $wp_meta_boxes[$current_screen->id]['normal']['core']['commentstatusdiv']['callback'] = function($post) {

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



add_action('add_meta_boxes', 'remove_trackbacks_pingbacks', 10, 2);

Lastly, since you want to remove the option from your edit screen, I assume you may want to remove from the quick edit screen as well. There are no hooks or classes to hook into that I know of, so a pure jQuery solution is in order. Insert into functions.php

Modified from this solution Here

    add_action( 'admin_head-edit.php', 'remove_pings_quickedit' );

function remove_pings_quickedit() 

    global $current_screen;
     if( 'edit-post' != $current_screen->id )
    <script type="text/javascript">         
        jQuery(document).ready( function($) {           
            $('span:contains("Allow Pings")').each(function (i) {
            $('input[name=ping_status]').each(function (i) {
  • Thanks for this - the remove_trackbacks_pingbacks is useful, but the method to get rid of the point of my question is the same as "method 2" in the answer I linked to, not really something I want to do for future code comparability. Thank you for the useful other snippets though.
    – Brett
    Commented Aug 7, 2018 at 12:23
  • Awesome, I'm glad remove trackbacksdiv did the trick. I don't have that div id available to target unfortunately, so I had to use method 2 but instead of removing the core commentsstatusdiv and replacing it with a custom meta box, an alternate solution is to just modify the original in the child theme. It should still work in the future should you want to further modify its contents, as long as WordPress doesn't change those core hooks. It does introduce a few extra variables though.
    – SHA3.org
    Commented Aug 8, 2018 at 14:57
  • Simply removing the trackbacksdiv with the first function should be pretty standard and stable though, unless you have a plugin modifying your metabox.
    – SHA3.org
    Commented Aug 8, 2018 at 15:06
  • Hmm yeah. It seems pretty much any way to handle this has it's shortcomings as there really is no official way to handle it unfortunately from what it seems. I'm starting ti think either CSS or JS is the cleanest way to get rid of it even if the targeted ID could change.
    – Brett
    Commented Aug 9, 2018 at 17:30
  • remove_meta_box('trackbacksdiv', 'post', 'normal'); is the official recommendation from the codex, so it's probably the safest bet. It's only a problem if you have extraordinary theme mods.
    – SHA3.org
    Commented Aug 10, 2018 at 4:11

Your code is correct, AFAIK. It will disable the ability to do trackback/pings. It doesn't remove that option from the screen, as you have noticed.

Not sure how to test that, though. But your code should work to disable the actual process of allowing trackback/ping.

This site might test trackback/pings https://tech.wizbangblog.com/ping.php . No experience with it, so YMMV.

  • Thanks. Removing the ability is the most important thing, but I guess removing the option to select that would also be nice so users don't go expecting it is supposed to work when they check it.
    – Brett
    Commented Jul 28, 2018 at 18:19
  • I suppose you could use some custom CSS to display:none those fields. Or dig into the source code of that page and find any possible filters to remove the field. Some custom CSS might be easier, although less 'pure'. Also, see the answer on this page: wordpress.stackexchange.com/questions/103502/… . Plus the answer to this question might be helpful: wordpress.stackexchange.com/questions/31943/… Commented Jul 28, 2018 at 19:19
  • Cheers - I'll take a look :)
    – Brett
    Commented Jul 28, 2018 at 20:07

The way described in the answer you point to is the easier to understand way using PHP. I agree that from a code stability POV it sucks as you need to make sure that nothing else ever changes in that meta box.

The other way to do it in php is to remove the core metabox, and create one of your own, in which you call the original one aand filter out the relevant output. It is still ugly, and you will have to write a long comment for it explaining the WHY of it, but it is more likely to remain stable than the first way.

Using JS or CSS to hide that checkbox is likely to be a much more stable idea. You are still betting against the ID being changed, but this is probably much less likely to happen and produce a much easier to understand code.

  • Some good options to consider, as there really doesn't seem like a proper, completely clean way to do this.
    – Brett
    Commented Aug 3, 2018 at 15:06

Here's the WordPress recommended way of doing it:

function remove_post_custom_fields() {
    // Remove Discussion meta box
    remove_meta_box('commentstatusdiv', 'post', 'normal');

    // Remove Comments meta box
    remove_meta_box('commentsdiv', 'post', 'normal');
add_action('admin_menu', 'remove_post_custom_fields');

Replace post with page or with another custom post type if needed.

Relevant codex link:


  • this is likely not to do what the OP asks for as it most likely removes the comment option as well. Commented Aug 3, 2018 at 9:40
  • Well, there are to remove_meta_box() calls. He could remove the second one. I have edited my answer and added code comments.
    – Ciprian
    Commented Aug 3, 2018 at 9:54
  • This removes the whole box including the "comments" part, not just the pingbacks/trackbacks option.
    – Brett
    Commented Aug 3, 2018 at 12:10
  • Remove this line - remove_meta_box('commentsdiv', 'post', 'normal'); - and it will keep the Comments box.
    – Ciprian
    Commented Aug 3, 2018 at 12:38
  • as its name implies remove_meta_box removes whole of the meta box, not just parts of it. Commented Aug 3, 2018 at 13:35

Please put below code on your theme's functions.php file. I hope it will work for you

function hide_ping_track() {    
    echo "<style>.meta-options label[for=ping_status], #ping_status{display:none !important;}</style>";      
add_action('admin_head-post.php', 'hide_ping_track');
  • This is not good at all. You shouldn't use CSS to hide these type of things/ Commented Aug 1, 2018 at 6:38
  • I don't think so .why it's not good can you please describe?
    – Trilok
    Commented Aug 1, 2018 at 6:41
  • downvoted as "place some code" without any explanation is just not an answer in the standards of this site. You should improved it and explain what it does at the very least Commented Aug 2, 2018 at 17:47

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.