wp eval

Execute arbitrary PHP code.

GitHub Issues

OPTIONS

<php-code>
The code to execute, as a string.
[--skip-wordpress]
Execute code without loading WordPress.

EXAMPLES

# Display WordPress content directory.
$ wp eval 'echo WP_CONTENT_DIR;'
/var/www/wordpress/wp-content

# Generate a random number.
$ wp eval 'echo rand();' --skip-wordpress
479620423

Command documentation is regenerated at every release. To add or update an example, please submit a pull request against the corresponding part of the codebase.