You can get things for the history by using the class SimpleHistoryLogQuery.
A quick example that displays the latest 5 rows from the log:
function simple_history_test_output() {
$log_query = new \Simple_History\Log_Query;
$simple_history = \Simple_History\Simple_History::get_instance();
$query_results = $log_query->query( [
'posts_per_page' => 5,
] );
printf(
'
<p>Found %1$d rows.</p>
<p>Viewing page %2$d of %3$d.</p>
',
esc_html( $query_results['total_row_count'] ), // 1
esc_html( $query_results['page_current'] ), // 2
esc_html( $query_results['pages_count'] ), // 3
);
echo "<ul>";
foreach ( $query_results['log_rows'] as $row ) {
$header_output = $simple_history->getLogRowHeaderOutput( $row );
$text_output = $simple_history->getLogRowPlainTextOutput( $row );
$details_output = $simple_history->getLogRowDetailsOutput( $row );
echo "<li>";
echo "<hr />";
echo "<p>{$header_output}</p>";
echo "<p>{$text_output}</p>";
echo "<p>{$details_output}</p>";
echo "</li>";
}
echo "</ul>";
}
Code language: PHP (php)
When running the above function the output will look something like this:

Available Parameters
The query() method accepts an array of parameters to filter and paginate results:
Basic Parameters
| Parameter | Type | Description |
|---|---|---|
posts_per_page | int | Number of events to return per page. Default: 10 |
paged | int | Page number for pagination. Default: 1 |
date_from | string | Filter events from this date (YYYY-MM-DD format) |
date_to | string | Filter events until this date (YYYY-MM-DD format) |
search | string | Search for events containing this text |
Inclusion Filters
Use these parameters to include only events matching specific criteria:
| Parameter | Type | Description |
|---|---|---|
loggers | array | Include only events from these loggers (e.g., ['SimplePostLogger', 'SimpleUserLogger']) |
loglevels | array | Include only events with these log levels (e.g., ['warning', 'error']) |
messages | array | Include only specific message types (format: ['LoggerSlug:MessageKey']) |
user | int | Include only events by this user ID |
users | array | Include only events by these user IDs |
initiator | string|array | Include only events by these initiators |
Exclusion Filters (Negative Filters)
Use these parameters to exclude events matching specific criteria. This is useful when you want to see all events except certain types:
| Parameter | Type | Description |
|---|---|---|
exclude_loggers | array | Exclude events from these loggers |
exclude_loglevels | array | Exclude events with these log levels |
exclude_messages | array | Exclude specific message types (format: ['LoggerSlug:MessageKey']) |
exclude_user | int | Exclude events by this user ID |
exclude_users | array | Exclude events by these user IDs |
exclude_initiator | string|array | Exclude events by these initiators |
exclude_search | string | Exclude events containing this text |
Note: When the same value appears in both an inclusion and exclusion filter, exclusion takes precedence.
Valid Initiator Values
wp_user– Regular WordPress user actionswp_cli– Actions performed via WP-CLIwp– WordPress system actions (cron jobs, automatic updates)web_user– Non-logged-in web visitorsother– Other sources
Examples Using Exclusion Filters
Here are some practical examples using exclusion filters:
$log_query = new \Simple_History\Log_Query();
// Exclude debug level events
$results = $log_query->query([
'posts_per_page' => 50,
'exclude_loglevels' => ['debug'],
]);
// Exclude WordPress system events (cron, auto-updates)
$results = $log_query->query([
'posts_per_page' => 50,
'exclude_initiator' => ['wp', 'wp_cron'],
]);
// Exclude events containing "cron" in the text
$results = $log_query->query([
'posts_per_page' => 50,
'exclude_search' => 'cron',
]);
// Exclude specific message types
$results = $log_query->query([
'posts_per_page' => 100,
'exclude_messages' => [
'SimplePluginLogger:plugin_activated',
'SimplePluginLogger:plugin_deactivated',
],
]);
// Combine inclusion and exclusion:
// Show user login events, but exclude admin user
$results = $log_query->query([
'posts_per_page' => 50,
'loggers' => ['SimpleUserLogger'],
'exclude_user' => 1, // Exclude admin (user ID 1)
]);
Code language: PHP (php)