How can I execute some small piece of PHP code in a sandbox area of my WP?

I’d like to execute some small piece of code like the following one:

global $wpdb;
$rows = $wpdb->query('SELECT DATE(post_date) AS date, COUNT(*) AS count FROM ' . $wpdb->posts . ' GROUP BY DATE(post_date) ORDER BY DATE(post_date)');
foreach ($rows as $row) {
    echo $row->date . ': ' . $row->count . '<br>';
}

But I don’t want to write a plugin for this small task. How can I manage it?

4 Answers
4

Best way for execute any PHP code during development its Console from Developer plugin. You can install Developer plugin, and activate console module. “Debug” link will appear in top right corner in your admin bar. You can go there, and execute any php code you like.

Leave a Comment