wp-cli post create & media import issues

So I just ended up doing a query on the database for the link of the image: wp db query “SELECT guid FROM wp_posts WHERE ID=’ID_FROM_MEDIA_IMPORT’” –silent –skip-column-names I wrote this bash script for the whole process: post-create.sh PATH_TO_IMAGE.FILETYPE “TITLE” imageID=$(wp media import $1 –porcelain) imageLINK=$(wp db query “SELECT guid FROM wp_posts WHERE ID=’$imageID'” –silent … Read more

Specify custom php.ini to use with WP-CLI

If executing PHP scripts directly on command line, you can try the -d option. Another way is to make use of the WP_CLI constant: if ( defined(‘WP_CLI’) && WP_CLI ) { // Load custom PHP configurations here. }

Bulk remove custom post type and its attachments with wp-cli?

To do this, you could use wp post list and pipe the output into wp post meta delete using xargs. Here’s an example command to delete the featured images in the meetings post type: wp post list –post_type= meetings –fields=ID –format=csv | xargs -I % wp post meta delete % _thumbnail_id You can use wp … Read more

Set Site Icon programmatically (eg. using `wp cli`)

The ‘official rules’ about site icons are here:https://www.w3.org/TR/html5/links.html#link-type-icon . They provide this example of site icons for several sizes: <link rel=icon href=favicon.png sizes=”16×16″ type=”image/png”> <link rel=icon href=windows.ico sizes=”32×32 48×48″ type=”image/vnd.microsoft.icon”> <link rel=icon href=mac.icns sizes=”128×128 512×512 8192×8192 32768×32768″> <link rel=icon href=iphone.png sizes=”57×57″ type=”image/png”> <link rel=icon href=gnome.svg sizes=”any” type=”image/svg+xml”> The above link also specifies if the ‘link … Read more