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

Update the permalink for one post via wp cli

If you mean the post name field, then we can update it for a post with: wp post update 123 –post_name=”new-slug” where 123 is the post ID. If we then try to update another post with the same post name: wp post update 321 –post_name=”new-slug” then it will be set to new-slug-2 in that case, … 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

WP-CLI can not find Url

Short answer: Read the documentation. Long answer: WP CLI needs to know your WordPress root directory. That is not platform, but software specific. This is also needed in Multisite and Network installs to determine the current site. The easiest way to solve this is to use a YAML configuration file for WP CLI. Best is … Read more