Support » Developing with WordPress » Comment search for post_title in wp-admin menu

  • Hello,

    I am trying to make the search field for comments under the admin menu search for
    post_title and possibly post_content.

    I found the function in the file: class-wp-comment-query.php and can see it only searches for: ‘comment_author’, ‘comment_author_email’, ‘comment_author_url’, ‘comment_author_IP’, ‘comment_content’.
    Since the coloumn “post title” is shown in in the table, i would like for the search field to also be able to search for words from that coloumn. But i am having trouble making it possible.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Joy

    (@joyously)

    The comments are stored separately from the posts, and only have the post ID, so it would be a complicated query to search on post_title or post_content.

    Moderator bcworkz

    (@bcworkz)

    Complicated indeed, but I’ve encountered worse. Your best option IMO is to develop a custom search routine that utilizes the specific SQL query that meets your needs. Execute your SQL query using one of the methods available in the global $wpdb object, an instance of the wpdb class which is connected to the WP DB.

    Coming up with the proper SQL is mainly a matter of joining in the appropriate tables and specifying the right WHERE clauses to get the results you want.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.