Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladimirlukyanov/e95a5fb0ebb2e87b29ae to your computer and use it in GitHub Desktop.
Save vladimirlukyanov/e95a5fb0ebb2e87b29ae to your computer and use it in GitHub Desktop.
Get all images from media library WordPress
<?php
$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 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment