Using WP-CLI, how do I delete a post by title or slug, not ID?

There is no wp-cli command to delete a post by title, but you could easily roll your own. Adding something like this in you current themes function.php file would work: if (defined(‘WP_CLI’) && WP_CLI) { class CYCLONECODE_WP_CLI_COMMANDS extends WP_CLI_Command { /** * Delete post by title. * * ## OPTIONS * * <title> * : … Read more

MySQL 5.6 Causes Errors with WP CLI

Resolved the issue. The problem was that the default PHP version changed with the new version of MAMP, and I had set the path in .bash_profile to the explicit version of the previous MAMP install. Once I edited the .bash_profile to dynamically find the version of PHP in use, everything works perfectly.

Get media url (featured image) with wp-cli

Assuming the attachment ID were in a variable of $attachment_id you could use the following command: # get attachment URL wp db query “SELECT guid FROM $(wp db tables *_posts) WHERE ID=\”$attachment_id\”” | head -n 2 | tail -1 I use the $(wp db tables *_posts) bit just in case the wp_ table prefix is … Read more

WP-CLI not working from Bash script

The reason is because the cron script’s environment has minimal configuration. When you as a user log into your system, additional environment variable are set which allow you to execute programs without explicitly defining the full path. The best way to fix this is to define the full path to your program(s) in your cron … Read more

Running custom defined WP-CLI commands without WordPress installation present

This may be helpful. http://wp-cli.org/blog/how-wp-cli-loads-wordpress.html This is what actually wp-cli tries. $_SERVER[‘HTTP_HOST’] = ‘example.com’; define(‘WP_ADMIN’, true); require(‘wordpress/wp-load.php’); You must have these WordPress files files and the database. So the answer is NO unless you create hack. I am not aware of any. If you pass: $ wp make:a.txt –skip-wordpress Error: This does not seem to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)