I am trying to overwrite a media post using the WordPress CLI.
The wp post create --post_type=attachment
command can create an empty media item, unable to be filled withbut cannot attach an image file through WP-CLI,WP-CLI. This is only possible through the GUI or other WP PHPWP PHP Functions (thus creating. The CLI command creates a "corrupt", media post. Is it better-to-avoid use from a WP-CLI user to avoid using this method?)
ByOn the other sidehand, the wp media import $filename
docommand does not include (according the Documentation) fields like the --post_name
,--post_date
among others "post"sand other post
fields, thus requiring a following. This method then requires running wp post update $id_media
for setting themthese fields once the post is created.
Hence, it is not possible tofor wp media import $filename
to overwrite a Media image with a givenpost that matches on --post_name
-WP. If you try this, WP actually just createcreates a duplicatedduplicate media object, with a new regenerated --post_name
-, thus all. This means the wp post exist
and wp post delete
process must be done "manually"manually as a part of this process.
Am I true with these observationsIs my thinking correct?