wp eval

Execute arbitrary PHP code.

GitHub Issues


The code to execute, as a string.
Execute code without loading WordPress.


# Display WordPress content directory.
$ wp eval 'echo WP_CONTENT_DIR;'

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

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.