Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define('WP_USE_THEMES', false);
- /** Loads the WordPress Environment and Template */
- require( dirname( __FILE__ ) . '/wp-blog-header.php' );
- ?><!DOCTYPE html>
- <html lang="en-US">
- <head>
- <meta charset="UTF-8" />
- <title>List JPG Files</title>
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- </head>
- <body>
- <h1>List JPG files</h1>
- <?php
- $args = array(
- 'post_type' => 'attachment',
- 'posts_per_page' => -1,
- 'post_status' => 'inherit',
- //'post_parent' => null, // any parent
- 'post_mime_type' => 'application/jpeg',
- );
- $query = new WP_Query( $args );
- if ( $query->have_posts() ) {
- echo '<ul>';
- while ( $query->have_posts() ) {
- $query->the_post();
- $image_info = wp_get_attachment_image_src( get_the_ID(), '416size' );
- echo '<li>', $image_info[0], '</li>';
- }
- echo '</ul>';
- /* Restore original Post Data */
- wp_reset_postdata();
- } else {
- echo '<p>No attachments found.</p>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement