Image Attributes Pro 3.0 ships with a Bulk action “Update image attributes“. This is added to the Bulk actions in WordPress Media Library, Posts, Pages and WooCommerce Products by default.
You can add this bulk action to other post types simply by adding the following code to the functions.php
of your active theme.
Remember to replace {$this->screen->id}
with the screen ID of the Edit post type screen before doing so.
/**
* Add Image Attributes Pro Bulk action "Update image attributes" to a post type.
*
* Remember to replace {$this->screen->id} with the screen ID of the Edit post type screen.
*
* @link https://imageattributespro.com/add-bulk-action-to-any-post-type/
*/
add_filter( 'bulk_actions-{$this->screen->id}', 'iaffpro_add_bulk_action_update_image_attributes_to_posts' );
add_filter( 'handle_bulk_actions-{$this->screen->id}', 'iaffpro_handle_posts_bulk_action_update_image_attributes', 10, 3 );
How To Find {$this->screen->id}
- To find the screen ID of the Edit screen of your post type, first navigate to the post type Edit page in WordPress admin.
- Then check source code of the page and you will see something like below. This example is from the Products list screen of WooCommerce products.
- To check the source code, simply right click anywhere and select
View source code
or similar option in most browsers. - Look for
pagenow = 'screen-id'
. - In this example,
edit-product
is the{$this->screen->id}
- In the code snippet,
bulk_actions-{$this->screen->id}
will have to bebulk_actions-edit-product
.
Please feel free to reach out if you have further questions.