1

How to hide (or not to show, better said) trackbacks on wp-admin/edit-comments.php page?

I want to hide the comments with no email (also known as trackbacks) and comments with a specific email from the edit-comments.php page.

2
  • you do want them enabled on the frontend?
    – janw
    Commented Sep 27, 2012 at 8:10
  • I want them to be shown on frontend, but not shown on the edit-comments.php and on the Dashboard widget named Recent Comments.
    – kingbt
    Commented Sep 27, 2012 at 8:20

2 Answers 2

0

While this is not impossible, this is very likely to have ton of edge cases and backfire in some. In a nutshell comments are retrieved with comment query, which can be adjusted with something like this (if in admin and comment type not specified then only fetch normal comments):

add_action( 'pre_get_comments', 'exclude_pings' );

function exclude_pings( $comment_query ) {

    if( ! is_admin() )
        return;

    if ( empty( $comment_query->query_vars['type'] ) )
        $comment_query->query_vars['type'] = 'comment';
}

However the problem is "any comment query in admin" is too broad and there isn't much it can be narrowed down by.

Overall I would not recommend to mess with this.

PS excluding by author is not supported by native arguments and would be even more tricky with need to filter SQL.

1
  • This helped me because I did not want to show trackbacks and a comment type named order_note (that has a specific repetitive email and author name). Thanks a lot and have a nice day.
    – kingbt
    Commented Sep 27, 2012 at 12:09
-1

To only show comments on the comments page.
Above the list there are 2 dropdowns one has the option to only show comments.

I checked the file which builds the data: class-wp-comments-list-table.php And the function prepare_items. It has no filters or actions to hook into.

As far as I can tell there is no way to disable trackbacks from showing.
Nor is excluding certain emails.

If you really want it you would have to copy the comment screen, and edit that. I can help you get started with that if you want.

2
  • You should leave this as a comment rather than an answer to keep the discussion in the same context. Commented Sep 27, 2012 at 9:56
  • Thanks, but I don't like hacking the core. Maybe a future version of WP will allow filters for this.
    – kingbt
    Commented Sep 27, 2012 at 11:58

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.