If you for example to be able to query images by category for whatever reason, you’ll want to enable category taxonomy for the attachment post type. You ca do that by adding the following 3 lines to your theme’s functions.php file:
function wb_220517_add_categories_to_attachments() { register_taxonomy_for_object_type( 'category', 'attachment' ); } add_action( 'init' , 'wb_220517_add_categories_to_attachments' );You can download the code for this how-to in