Title: log_query_custom_data
Published: November 12, 2019
Last modified: February 24, 2026

---

# apply_filters( ‘log_query_custom_data’, array $query_data, string $query, float $query_time, string $query_callstack, float $query_start )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/log_query_custom_data/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/log_query_custom_data/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/log_query_custom_data/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/log_query_custom_data/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/log_query_custom_data/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/hooks/log_query_custom_data/?output_format=md#wp--skip-link--target)

Filters the custom data to log alongside a query.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/log_query_custom_data/?output_format=md#description)󠁿

Caution should be used when modifying any of this data, it is recommended that any
additional information you need to store about a query be added as a new associative
array element.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/log_query_custom_data/?output_format=md#parameters)󠁿

 `$query_data`array

Custom query data.

`$query`string

The query’s SQL.

`$query_time`float

Total time spent on the query, in seconds.

`$query_callstack`string

Comma-separated list of the calling functions.

`$query_start`float

Unix timestamp of the time at the start of the query.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/log_query_custom_data/?output_format=md#source)󠁿

    ```php
    $query_data = apply_filters( 'log_query_custom_data', $query_data, $query, $query_time, $query_callstack, $query_start );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wpdb.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wpdb.php#L2399)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wpdb.php#L2399-L2399)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/log_query_custom_data/?output_format=md#related)󠁿

| Used by | Description | 
| [wpdb::log_query()](https://developer.wordpress.org/reference/classes/wpdb/log_query/)`wp-includes/class-wpdb.php` |

Logs query data.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/log_query_custom_data/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.3.0](https://developer.wordpress.org/reference/since/5.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Flog_query_custom_data%2F)
before being able to contribute a note or feedback.