wp cli media commands not working

Media is the post type (post_type=”attachment”), so most operations are done with wp post command. By default, wp post manage blog posts (post_type=”post”), therefore by fetching post IDs you must add –post_type=attachment indicating the type of posts. And to update media meta you should use wp post meta update <id> <key> <value> Your entire command … Read more

Add Filename Colum to Media Library

Found the solution: I just changed “name” to “Filename” on this function: // Register the column as sortable & sort by name function filename_column_sortable( $cols ) { $cols[“filename”] = “Filename”; return $cols; }

Store images and videos category wise and fetch them in json format

Some how able to get all the images from media library. This is very close. $query_images_args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘post_status’ => ‘inherit’, ‘posts_per_page’ => – 1, ); $query_images = new WP_Query( $query_images_args ); $images = array(); foreach ( $query_images->posts as $image ) { $images[] = wp_get_attachment_url( $image->ID ); }